1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
char c;
do{
c = (char)getch();
if (c == KEY_LEFT)
{
x = x - 10, x1 = x1 - 10;
}
if (c == KEY_RIGHT)
{
x = x + 10, x1 = x1 + 10;
}
line(300, 15, 300, 600);//left Border
line(500, 15, 500, 600);//right Border
bar(x, y, x1, y1);//the moving body of the car
Obstacles();//Calling the obstacles function.
cleardevice();
void Obstacles()//Obstacles function
{
int q = 320, w = 0, e = 350, r = 30;
for (int i = 0; i < 60; i++)
{
w = w + 10;
r += 10;
rectangle(q, w, e, r);
Sleep(100);//this stops the moving controls to move the object's car
cleardevice();//when I write this the other objects disappears
}
}while(true);
|