This is a snake game programmed in Java. The code for this game was written using an object-oriented programming approach and the UI was created using Swing components.
Assuming Java and Apache Maven are installed, run the following command in the project's root directory:
mvn clean install
After building the project, run the following commands in the project's root directory:
cd target
java -jar java-snake-v1.1.0.jar
The goal of the game is to navigate the snake's head to the food piece on the game map. Every time a food is eaten by the snake, the score is increased by 15
points. Additionally, the snake grows one unit longer and also a new food piece is generated at a random coordinate where the snake is not located. Beware though! If the snake's head goes out of bounds or intersects with its body then it's game over.
The controls for the game are:
Key(s) | Action |
---|---|
β or W | Changes the snake's movement direction to up. |
β or A | Changes the snake's movement direction to left. |
β or S | Changes the snake's movement direction to down. |
β or D | Changes the snake's movement direction to right. |
Spacebar | Starts the game if it hasn't been started yet. |
P | Pauses/unpauses the game. |