![]() |
|
Simple HC text animation - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: C, C++, & Obj-C (https://sinister.ly/Forum-C-C-Obj-C) +--- Thread: Simple HC text animation (/Thread-Simple-HC-text-animation) |
Simple HC text animation - alok9shm - 06-29-2014 I was getting bored, so coded this extremely simple Animation in C. The output: ![]() Compiler used: Turbo C++ [Yes, I still use this good old compiler apart from GCC] The Source Code: Code: #include<graphics.h>
#include<dos.h>
#include<conio.h>
#include<stdio.h>
int main()
{
int i, gd = DETECT, gm;
initgraph(&gd,&gm,"c:\\turboc3\\bgi"); //path to your bgi folder in double quotes
settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
outtextxy(25,240,"Press any key to start rolling HC");
getch();
setviewport(0,0,639,440,1);
for( i = 0 ; i <= 420 ; i = i + 10 )
{
rectangle(40+i,250,70+i,400); //the 1st vertical line in H (|)
rectangle(140+i,330,70+i,300); //the horizontal line in middle of H (-)
rectangle(140+i,250,170+i,400); the last vertical line in H (|)
ellipse(280+i,320,60,300,90,80); //for the outer part of C
ellipse(280+i,320,60,300,70,60); //inner part of C
setcolor(RED);
delay(100);
if( i == 420 )
break;
clearviewport();
}
getch();
closegraph();
return 0;
}RE: Simple HC text animation - ArkPhaze - 06-29-2014 Why getch()? Also: Code: i = i + 10Code: i += 10Cool simple little animation though.. RE: Simple HC text animation - alok9shm - 06-29-2014 (06-29-2014, 09:20 AM)ArkPhaze Wrote: Why getch()? To hold the screen even after the execution is complete. It accepts a keyboard input and then terminates the console window. Its really a headache for me in TC, if I don't use a getch() before the end of main(). Every time, I run the code, the console window does its job and disappears automatically. If its a small program, it will execute and terminate at the blink of an eye, without showing me the output. So, I use getch() while using TC. Its like Hey Output window, do not disappear unless I order you to do so.
RE: Simple HC text animation - ArkPhaze - 06-29-2014 I did not mention getch() because I didn't know what it did... I mentioned it because it's not standard. There are alternatives that are, however. RE: Simple HC text animation - alok9shm - 06-29-2014 (06-29-2014, 12:24 PM)ArkPhaze Wrote: I did not mention getch() because I didn't know what it did... There are alternatives that are, however. I know The reputation says all. So, how do I overcome this? Any suggestions? and how do I complete the C? you can see that C is not bounded like H. I tried using another 2 lines but that would make it messy. Any simpleway out?
|