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
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