You are tasked with developing a Java version of the classic game Snake. The game will allow a user to control the movement of the snake using the keyboard’s cursor controls. The player will initially control a three-circle player object (Snake with red head and green body), which will move one cell at a time on the X or Y axis, representing the game world. As the player consumes the green apples, the snake will in turn grow by 1 (the apple and red and green circles will be provided to you as PNG images).
If the snake collides with itself, then the game is over, and you may prompt the user to play again. If the user consumes an apple, the apple will disappear and the length of the snake will be incremented by one. Apples eaten by the snake will be replaced immediately and are to be placed at random, on another square not currently occupied by the player’s snake or another item or obstacle. You can use a grid for the game world, if you wish.
You must use the GameEngine code provided as part of the course, you can not use any other engine or graphics framework (except those also used by the game engine such as Java awt). Your game must be written in Java.
The snake can move into the cells immediately adjacent to itself but it cannot move back on itself.
The snake will be moving forward in its current direction at all times.
Use an Array or an ArrayList to represent the body of the snake using a maximum of 20 circles (including it’s head). You will need an extra variable to keep track of the current size of the snake.
When the snake moves to a new cell, all the previous snake cells will be shuffled down by one array element. You will also need to keep track of which direction the head of the snake is moving.
The game will end if the snake collides with itself or with the borders of the game.
Make sure your code compiles without errors. You will lose marks if there are any compilation errors.
Produce an Object Orientated game architecture. Develop and render a game world.
Object Orientated Game Architecture – 8 Marks
Working Game Architecture Code – 7 Marks
Working Game Code – 5 Marks
Keyboard Input Code – 5 Marks
Develop code to respond to user input in the event processing section of the main game loop. The user input should be translated into code to allow the control of the snake player character.
Working Keyboard Input code – 7 Marks
Event Handling and Control of the Player Character – 4 Marks
Working Event Handler Code – 4 Marks
Code to shift all existing snake positions down by one array element – 10 Marks
Develop code to allow the snake to grow by one cell when it eats an apple. This code will need to allow the snake to grow by one cell, and will need to shift all the snake cell positions down by one.
The game should compile with no errors or warnings.
Random placement of apples with respect to other game objects – 4.5 Marks
Code to add a new element to the snake array / list – 3 Marks
Working code to add new elements to the end of the snake array – 2.5 Marks
Working code to shift array elements – 10 Marks
Produce code for additional features you can think about to enhance the game. Marks will be allocated based on the complexity of the extra features. Examples can include (but are not limited to):
Two players playing the snake game. For example, a blue snake is controlled with “W,A,S,D” keys and a green snake is controlled with “Arrow Keys”
Setting up a start Menu with different options: Play, Help, Quit
If the game ends, the user can be notified of this and prompted to play the game again
Introduce a Game Grid
Introduce four lives for the Snake, so the player is given four opportunities before the game is over. Introduce a food item that will reduce snake’s lives, if the snake eats it
Other features you can think of…
This is an individual assignment. You must work on the individual tasks by yourself and all work on these tasks must be your own. When submitting the work via Stream, as part of your assessment submission you agree that the work is your work and your work alone.
If you are using any online code, please make sure you include the link and acknowledge the source in the comment section.
Your submission should include the source code as well as a one-page document or a README.txt file explaining how to run the code as well as a list of all additional features you have implemented (if any).
You must submit a zip file generated by IntelliJ, to do this use File..Export..Project to zip File.