#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <conio.h>
int main()
{int i,j;
int x=1,y=5;
int velocity_x=1;
int velocity_y=1;
int left=0;
int right=100;
int top=0;
int bottom=20;
int x1=bottom+1;
int a[21][100];
int board_x=8;
int board_v=4;
int board_l=10;
while(1)
{x=x+velocity_x;
y=y+velocity_y;
for(i-0;i<21;i++)
{for(j=0;j<100;j++)
{a[i][j]=0;
}
}
system("cls");
for(j=0;j<y;j++)
{printf("\n");
}
for(i=0;i<x;i++)
{printf(" ");
}
a[y][x]=1;
printf("o");
if (_kbhit())
{switch(getch())
{case'a':
case'A':
board_x-=board_v;
break;
case'd':
case'D':
if(board_x<(right-board_l))
board_x+=board_v;
break;
}}
for(j=0;j<21-y-1;j++)
{printf("\n");
}
int board_100=board_x;
for(j=0;j<board_l;j++)
{printf("+");
a[21-1][board_100-1]=2;
board_100++;}
Sleep(50);
if((x==left)||(x==right))
velocity_x=-velocity_x;
if(y==top)
velocity_y=-velocity_y;
if(y==x1-2)
{if(a[21-1][x]==2||y==0)
{velocity_y=-velocity_y;}
}
if(y==21)
{printf("gameover\n");
getchar();
exit(0);
}
}}