Text Animation in C/C++



Hey guys, in this article, I'm going to let you know a method which is defined inside of `conio.h` , and then how this method helps to achieve this. 

As I told this is a predefined method which is defined inside "conio.h" header file.

Declaration:
void window(int left, int top, int right, int bottom);

window defines a text window on-screen, which means you can display your statements or text on located space on the window (o/p) screen.

there are 4 parameters required for specifying the coordinates to display the text on the window screen,

Example


#include <conio.h>
#include <dos.h>

int main() {
  int i;

  for (i = 25; i >= 1; i--) {
    clrscr();
    window(20, i, 70, 25);

    textcolor(2);

    cprintf("This program intruduced by Abdul Rizwan\r\n\n");
    delay(500); // halt for half second [1000 = 1second]
    if (i == 1)
      i = 25; // reinitialize of i
  }

  return 0;
}

 here as I defined window(20, i, 70, 25)

  • [ 20 (left),  i (top) ] : this will start from 20 left and i=25 (top) coordinator, [which means it will start from the bottom of window screen] and i(top) is decreased by one until i!=0.

  • [70 (right), 25(bottom) ]: 70 is the maximum length of the screen right coordinator, upto 70 that statement can be displayed, means your text will start from 20 and its range is 70 [upto 70 cols this text will be displayed] and 25 is bottom coordinate as I have given the input value.


        



To understand this concept, would like to recommend you to write your own program and test it. Thanks




Comments

  1. this coding not working for dev or visual c++

    how to work dev or visual c++

    please answer

    ReplyDelete
  2. How about only specific statement and not all statement are animate? because.. you use clrscr() this will clear all what in the screen..

    ReplyDelete

Post a Comment