Skip to content

BeardedFish/Snake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

27 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Snake 🐍

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.

How to Build

Assuming Java and Apache Maven are installed, run the following command in the project's root directory:

mvn clean install

How to Run

After building the project, run the following commands in the project's root directory:

cd target
java -jar java-snake-v1.1.0.jar

How to Play

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.

Screenshots

Game that hasn't been started Game over Game paused High score window