A classic Snake game built from scratch with Java Swing.
- JDK 11 or higher installed on your system
- Maven (optional, for building from source)
git clone https://github.com/theinfinull/snakegame-java.git
cd snakegame-java- Windows: Double-click
run.bat - Linux/macOS: Run
./run.shor double-clickrun.sh
# Compile the project
mvn clean compile
# Run the game
java -cp target/classes com.infinull.App# Build the JAR file
mvn clean package
# Run the JAR
java -jar target/snakegame.jar- Start the game using any of the methods above
- Navigate the menu using arrow keys or mouse
- Control the snake using arrow keys:
- ⬆️ Up Arrow - Move up
- ⬇️ Down Arrow - Move down
- ⬅️ Left Arrow - Move left
- ➡️ Right Arrow - Move right
- Eat food to grow longer and increase your score
- Avoid walls and yourself - Game over if you hit them!
- Beat your high score and challenge yourself!
snakegame-java/
├── src/
│ └── main/
│ ├── java/
│ │ └── com/infinull/
│ │ ├── App.java # Main entry point
│ │ ├── SnakeGame.java # Game logic
│ │ ├── SnakeMenu.java # Menu system
│ │ └── Config.java # Configuration
│ └── resources/
│ ├── snake/ # Snake sprites
│ ├── food/ # Food sprites
│ ├── highscore/ # High score data
│ └── *.png # UI assets
├── sample/ # Screenshots
├── pom.xml # Maven configuration
├── run.sh # Linux/macOS run script
└── run.bat # Windows run script
This project is open source and available under the MIT License.
Made with ❤️ using Java
⭐ Star this repo if you find it helpful!


