I received an assignment to build the Snake game, and I provided with the following 'gotoxy' function:
void gotoxy(int y, int x) {
printf("\x1b[%d;%df", x + 1, y + 1);
}
which i should use to print the borders and the snake on the console.
First, I tried to print the borders of the game, but when I run the code the console prints this:
The printing borders functions:
void printBorders(){
int initX = 0;
int initY = 7;
printCols(initX, initY);
printLines(initX, initY);
printCols(initX, initY + 25);
printLines(initX + 75, initY);
return;
}
void printCols(int x, int y){
while(x <75)
{
gotoxy(x, y);
printf("#");
x++;
}
return;
}
void printLines(int x, int y){
while (y < 32)
{
gotoxy(x, y);
y++;
printf("#");
}
But I don't know what is the problem and how to fix it, thank you for your help.