Creating moving bar in tubro c is very easy just go through the following code:
You can download the Complete file by clicking Download
Place the downloaded file in C:\TC\BGI
Download
#include<stdio.h>
#include<graphics.h>
#include<conio.h>
void main()
{
int l,i=250,j=400,x=0,y=-1,ch,gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\TC\\BGI");
while(100)
{
bar(i,j,i+100,j+30);
ch=getch();
if(kbhit())
{
ch=getch();
if(ch==75)
{
x=-1;
y=0;
}
if(ch==77)
{
x=1;
y=0;
}
if(ch==27)
{
exit(0);
}
}
i=i+x;
j=j+y;
cleardevice();
}
}
You can download the Complete file by clicking Download
Place the downloaded file in C:\TC\BGI
Download
#include<stdio.h>
#include<graphics.h>
#include<conio.h>
void main()
{
int l,i=250,j=400,x=0,y=-1,ch,gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\TC\\BGI");
while(100)
{
bar(i,j,i+100,j+30);
ch=getch();
if(kbhit())
{
ch=getch();
if(ch==75)
{
x=-1;
y=0;
}
if(ch==77)
{
x=1;
y=0;
}
if(ch==27)
{
exit(0);
}
}
i=i+x;
j=j+y;
cleardevice();
}
}
No comments:
Post a Comment