Graphics.h

Hi this is my very first post on c++.com........ i have been trying to make a box moving game ,,,where the goal is to make it reach a specific pt ...but the prob is cleardevice();
as it removes evrything .... even the goal pt



#include<iostream.h>
#include<conio.h>
#include<dos.h>
#include<graphics.h>
void main()
{
clrscr();
int driver = DETECT,mode;
int i,x=75,y=75,x1=125,y1=125;
initgraph (&driver,&mode,"C:\\TC\\BGI");
rectangle(75,75,125,125);
int ch='f',c=10,cof=0,cod=0,col=0,cor=0;
cout<<"press WASD or q to quit";
ch=getch();
cout<<ch;
while((ch!='q')||(ch!='Q'))
{ch=getch();
if((ch=='s')||(ch=='S'))
{
cod=cod+1;
cof=0;
y=y+cod*5;
y1=y1+cod*5;




cleardevice();
rectangle(x,y,x1,y1);
}
if((ch=='w')||(ch=='W'))
{
cof=cof+1;
cod=0;
y=y-cof*5;
y1=y1-cof*5;
cleardevice();

rectangle(x,y,x1,y1);
}
if((ch=='a')||(ch=='A'))
{
col=col+1;
cor=0;
x=x-col*5;
x1=x1-col*5;
cleardevice();
rectangle(x,y,x1,y1);
}
if((ch=='d')||(ch=='D'))
{
cor=cor+1;
col=0;
x=x+cor*5;
x1=x1+cor*5;
cleardevice();
rectangle(x,y,x1,y1);
}



if(ch=='q')
{
break;
}
}





getch();

closegraph();
}
Topic archived. No new replies allowed.