Your program is asking drawPixel to draw a pixel that is off the screen.
OK the message box and hit the stop button on the VM Emulator.
The Call Stack shows snake.drawSnake called drawPixel.
class snake{
field int length, dir;
field Array x,y,coordinate, operation;
...
method void drawSnake(){
var int count;
>>> var Array x,y; <<< delete this line
let count = 0;
do Screen.clearScreen();
while (count < length){
do Screen.setColor(true);
do Screen.drawPixel(x[count],y[count]);
let count = count + 1;
}
return;
}
The local variable declaration of x and y overrides the field declaration
of x and y. These local x and y are initialized with 0 so x[count] and
y[count] read values from RAM[0+count], and these values are too big to
be screen coordinates.