void draw(char main [][75], int score);
void reset(char main[][75]);
void Move(char main[][75], int &parts, int pastcounter, int past[][2], int &apples, int &score, int &quit);
void check (int &direction);
void directionn(int direction, int &pastcounter, int past[][2]);
void apple (int &apples, char main[][75]);
void quitgame (int score);
int main()
{
int past[1000][2];
int parts = 3;
char main[23][75];
int pastcounter = 6;
int direction = 0;
int apples = 0;
int score = 0;
int quit = 0;
int playagain = 1;
srand(time(0));
}
quitgame(score);
Sleep (10000);
//getch();
}
void draw(char main[][75], int score)
{
system("cls");
printf ("Score : %d\n", score);
for (int x = 0; x < 23; x ++)
{
for (int y = 0; y < 75; y ++)
{
printf ("%c", main[x][y]);
}
printf ("\n");
}
}
void reset(char main[][75])
{
for (int x = 0; x < 23; x++)
{
for (int y = 0; y < 75; y++)
{
if (main[x][y] == '@')
{
main[x][y] == '@';
}
else
{
if (x == 0 || x == 22 || y == 0 || y == 74)
{
main[x][y] = 177;
}
else
{
main[x][y] = ' ';
}
}
}
}
}
void Move(char main [][75], int &parts, int pastcounter, int past[][2], int &apples, int &score, int &quit)
{
for (int x = 0; x < parts; x++)
{
if (main[past[pastcounter - x][0]][past[pastcounter - x][1]] == '@')
{
apples--;
parts++;
score += 10;
}
if (main[past[pastcounter - x][0]][past[pastcounter - x][1]] == 'o')
{
quit = 1;
}
else
{
main[past[pastcounter - x][0]][past[pastcounter - x][1]] == 'o';
}
}
}
void check (int &direction)
{
int key = 0;
if (kbhit())
{
key = -getch();
switch (key)
{
case -72:
direction = 2;
break;
case -77:
direction = 0;
break;
case -80:
direction = 3;
break;
case -75:
direction = 1;
break;
}
}
}
void directionn(int direction, int &pastcounter, int past[][2])
{
int right;
int down;
right = past[pastcounter][1];
down = past[pastcounter][0];
switch (direction)
{
case 0:
right ++;
break;
case 1:
right --;
break;
case 2:
down --;
break;
case 3:
down ++;
break;
}
pastcounter ++;
past[pastcounter][0] = down;
past[pastcounter][1] = right;
}
void apple (int &apples, char main[][75])
{
int up = 0;
int left = 0;
apples = 3;
for (int x = 0; x < apples; x ++)
{
up = (rand() % 22);
left = (rand() % 74);