void clearscreen(); //used to prevent flicker
void movement(int left, int right, int up, int down, int &y, int &x); //used to recoodrinate the snake
int main() {
char map[20][40]; //decleares the map
//loads the bottom and top of the map with a border
for(int i=0; i < 40; ++i) {
map[0][i] = '#';
map[19][i] = '#';
}
//loads the rest of the map with vertical borders and space between them
for(int i=1; i < 19; ++i) {
for(int j=0; j < 41; ++j) {
map[i][0] = '#';
map[i][39] = '#';
if(j < 39) {
map[i][j] = ' ';
}
}
}
char snake = 'o';
int y=9, x=19; //used to coordinate the snake
int left=0, right=0, up=0, down=0; //used to determine which direction the snake should go
int foodcount = 0; //counts ammount of food eaten
int eaten = 0; //used to check if the snake ate food
//generates the food
char food = 'x';
int a, b; //used to position the food
srand(time(0));
a = rand() % 17 + 1;
Sleep(25);
b = rand() % 37 + 1;
map[a][b] = food;
for(;;) { //the game loop
clearscreen();
map[y][x] = snake; //places the snake