Problem with width/2 and height/2

you need to write
snakePosX = width / 2;
snakePosY = height / 2;

after the size (500, 500); because before that the window size is (100, 100) also the generic size

1 Like