Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/beardedfish/snake

Snake game programmed in Java using Swing. 🐍
https://github.com/beardedfish/snake

classic-game food game high-score io java maven painting panel scoring-system snake swing wasd

Last synced: 28 days ago
JSON representation

Snake game programmed in Java using Swing. 🐍

Awesome Lists containing this project

README

        

# 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](https://en.wikipedia.org/wiki/Swing_(Java)) components.

## How to Build

Assuming [Java](https://www.java.com/en/) and [Apache Maven](https://maven.apache.org/) are installed, run the following command in the project's root directory:

```shell
mvn clean install
```

### How to Run

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

```shell
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](screenshots/screenshot1.png "Game that hasn't been started")
![Game over](screenshots/screenshot2.png "Game over")
![Game paused](screenshots/screenshot3.png "Game paused")
![High score window](screenshots/screenshot4.png "High score window")