startingLength=5 which will control the length of the snake at the start of each level. This is not the same as the current length of the snake, which will change every time an apple is eaten once you reach Phase 4). It is a variable, not a constant, because higher levels will start with longer snakes (once you reach Phase 6). For Question 1, a fixed value of 5 is OK. Define a function void resetSnake() which will set the current length of the snake to the startingLength , and create a snake of that length with its head in the centre of the top row, and going straight up from there. (All of the circles except the head will be above the top of the canvas at first, with negative y coordinates) Use your fillArray function to create the snake. Define a function void moveSnake(int addX, int addY) which will move the snake by creating anew head adjacent to the old head, by adding the indicated numbers to the x and y coordinates. (Sob moveSnake(1,0)bwill move it right, moveSnake(0,-1) will move it up, etc) The coordinates of the head of the snake should always be stored at index [0] of your arrays. The old head, and the other parts of the snake, should shift over one place in the array, except for the tail, which should disappear. The length of the snake should not change. Create appropriate setup and draw functions. Define a variable snakeSpeed to control the speed with which the snake moves. Every snakeSpeed frames, you should move the snake. Try a value of 30, which will make the snake move once every half second. Do not change the frame rate For test purposes in this question, always move the snake downward. You should see a snake, 5 circles long, that starts at the top of the canvas, in the middle, with only its head showing at first, and which moves slowly down the canvas, until it disappears off the bottom. Choose your own custom colours for the background, and the snake.
ASSIGNMENT 5: The Snake Game DEPARTMENT AND COURSE NUMBER COMP 1010 4