Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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. 🐍
- Host: GitHub
- URL: https://github.com/beardedfish/snake
- Owner: BeardedFish
- Created: 2020-05-22T19:19:02.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-07-12T04:55:57.000Z (over 1 year ago)
- Last Synced: 2024-11-06T14:48:51.456Z (3 months ago)
- Topics: classic-game, food, game, high-score, io, java, maven, painting, panel, scoring-system, snake, swing, wasd
- Language: Java
- Homepage: https://www.darianbenam.com/download-preview.php?id=3
- Size: 173 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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")