if (x >= width) x =0;else if (x <0) x = width -1; if (y >= height) y = 0; else if (y < 0) y = height - 1; for (int i =0; i< nTail ;i++) if (tailX[i] == x && tailY[i] == y) gameover = true; if (x == fruitX && y == fruitY) { score +=10; fruitX = rand() % width; fruitY = rand() % height; nTail ++; } } int main() { Setup(); while (!gameover) { Draw (); Input (); algorithm (); } return 0; }