Hi!
Anyone knows how to write an animation program in BGI graphics? I want to write a program that a ball will bounce from the edges of the screen.
Any ideas?
Hi!
Anyone knows how to write an animation program in BGI graphics? I want to write a program that a ball will bounce from the edges of the screen.
Any ideas?
Current projects:
1) User Interface Development Kit (C++)
2) HTML SDK (C++)
3) Classes (C++)
4) INI Editor (Delphi)
One thing you can do is maybe look at some pascal code http://www.geocities.com/SiliconVall.../pasl2007.html
And then notice the calls to getimage and
putimage.
#include<graphics.h>
#include<alloc.h>
main()
{
int gd=DETECT,gm,area,x=50,y=50,ch,xdirn=1,ydirn=1;
int maxx,maxy;
char *buff;
initgraph(&gd,&gm,"c:\\tc\\bgi");
setcolor(YELLOW);
setfillstyle(SOLID_FILL,BLUE);
circle(100,100,50);
floodfill(100,100,YELLOW);
area=imagesize(50,50,150,150);
buff=malloc(area);
getimage(50,50,150,150,buff);
maxx=getmaxx();
maxy=getmaxy();
rectangle(0,20,maxx,maxy);
outtextxy(250,10,"Animation");
while(1)
{
if(kbhit())
{
ch=getch();
if(ch=='\r')
{
xdirn*=-1;
ydirn*=-1;
}
else
{
if(ch==27)
break;
}
}
putimage(x,y,buff,XOR_PUT);
delay(0);
x=x+(xdirn*5);
y=y+(ydirn*2);
putimage(x,y,buff,XOR_PUT);
if(x<maxx-50||x<0)
{
sound(50);
delay(10);
nosound();
xdirn*=-1;
}
if(y>maxy-50||y<20)
{
sound(50);
delay(10);
nosound();
ydirn*=-1;
}
}
getch();
closegraph();
restorecrtmode();
Then where i can get the
graphics.h
alloc.h ?
______________________
Wut ?