This is a simple and fun version of the classic Snake game developed using Java Swing. The game is controlled with arrow keys and includes a basic scoring system.
The game screen displays the snake, food (apples), and current score at the top.
- Java JDK 8 or later
- Any Java IDE (e.g., IntelliJ IDEA, Eclipse, VS Code) or terminal
javac
andjava
must be available in your system PATH
javac -d bin src/SnakePackage/*.java
java -cp bin SnakePackage.SnakeGame
You can run the game directly on Windows using the included Snake.exe
file.
Use Snake_Setup.exe
(created with Inno Setup) to install the game.
- You start as a snake with 6 body parts.
- Red circles represent apples.
- Every time you eat an apple:
- The snake grows longer
- Your score increases
- The game ends if you hit the wall or collide with your own body.
- After a game over, press
Enter
to restart.
Key | Action |
---|---|
⬅️ Left | Move left |
➡️ Right | Move right |
⬆️ Up | Move up |
⬇️ Down | Move down |
⏎ Enter | Restart the game |
SnakeProject/
├── src/
│ └── SnakePackage/
│ ├── SnakeGame.java
│ ├── GameFrame.java
│ └── GamePanel.java
├── bin/ # Compiled classes (via javac -d)
├── screenshot.png # Game screenshot (optional)
├── Snake.exe # Executable file (from Inno Setup)
├── Snake_Setup.exe # Installer (optional)
└── README.md
- Java 8+
- Java Swing (for GUI)
- Inno Setup (for Windows installer)
This project is licensed under the MIT License – see the LICENSE file for details.
Enjoy the game! 🕹️