#include
#include
#include
char bg[25][80];
int playerX = 10;
int playerY = 10;
void PrintfScreen(void);
void ClearScreen(void);
void GameMain(void);
void main(void)
{
for(;;)
{
ClearScreen();
GameMain();
PrintfScreen();
}
}
void PrintfScreen(void)
{
bg[24][79] = 0;
printf("%s",bg);
}
void ClearScreen(void)
{
system("cls");
for(int y= 0; y<25;y++)
{
for(int x=0; x< 80;x++)
{
bg[y][x] = ' ';
}
}
}
void GameMain(void)
{
char pressKey=0;
if(kbhit())
{
pressKey = getch();
switch(pressKey)
{
case 72:
playerY--;
if(playerY < 1 )
playerY = 1;
break;
case 75:
playerX--;
if(playerX < 0)
playerX = 0;
break;
case 77:
playerX++;
if(playerX > 75)
playerX = 75;
break;
case 80:
playerY++;
if(playerY > 23)
playerY = 23;
break;
}
}
bg[playerY - 1][playerX + 0] = '-';
bg[playerY - 1][playerX + 1] = '>';
bg[playerY + 0][playerX + 1] = '>';
bg[playerY + 0][playerX + 2] = '>';
bg[playerY + 0][playerX + 3] = '>';
bg[playerY + 1][playerX + 0] = '-';
bg[playerY + 1][playerX + 1] = '>';
}