Exported from Notepad++
// Fun Snake 1 // Snake Constants var SNAKE_DIM = 10; var SNAKE_COLOR = Color.green; // Constants to represent the directions var EAST = 0; var SOUTH = 1; var WEST = 2; var NORTH = 3; var snake; var currentDirection = EAST; function start() { // TODO: create the snake and add it to the canvas setTimer(draw,50); keyDownMethod(keyDown); } function draw() { addTrail(); if (currentDirection == EAST) { snake.move(SNAKE_DIM,0); } // TODO: add the other three directions } function keyDown(e) { if (e.keyCode == Keyboard.LEFT) { currentDirection = WEST; } // TODO: add the other three directions } function addTrail() { //TODO: Add another rectangle at the current // position of the snake to act as the tail // the x and y coordinates of the snake can // be found using snake.getX() and snake.getY() // Refer back to the TRAIL exercise for an example }