An implementation of the classic Snake arcade game, built entirely in Java Swing.
- Complete game states: Main Menu, Gameplay, Game Over
- Visual polish: Sprites, themed backgrounds, and smooth animations
- Audio: Background music + sound effects (hiss, apple crunch, game over)
- Persistence: High score saved between sessions
- Responsive controls: Arrow keys
- State Management: Clean separation of UI screens using
JPanelstates - Threading: Safe game loop with proper shutdown (
interrupt(),join()) - Asset Management: Centralized
SpriteManagerandSoundManager - File I/O: High score persistence with error-safe loading/saving
- Swing Best Practices: Proper EDT usage, layout management, and rendering
- Modular Design: Entities, panels, and utilities cleanly separated
- Use arrow keys to control the snake
- Eat apples to grow and increase your score
- Avoid walls and colliding with yourself!
- Beat your high score and hear satisfying audio feedback
- Java 11 or higher
git clone https://github.com/rowanvictor01/snake-game.git
cd snake-game
# Linux/macOS
javac -d out $(find src -name "*.java")
# Windows Powershell
javac -d out (Get-ChildItem src -Recurse -Include *.java).FullName # Windows Powershell
# Windows CMD
javac -d out src\main\*.java src\panels\*.java src\utils\*.java src\entities\*.java
java -cp out main.Main
# OR
# Import into IntelliJ/Eclipse and run `Main.java`All visual and audio assets are credited here. Special thanks to the creators on OpenGameArt.org and Freesound.org for their generous contributions under CC BY and CC0 licenses.
src/
├── entities/ # Game objects (Snake, Apple)
├── main/ # Core game logic (GameController, Window)
├── panels/ # UI screens (MainMenuPanel, GamePanel, etc.)
└── utils/ # Utility classes (SpriteManager, SoundManager, HighScoreManager)
This project is licensed under the MIT License. Note: Game assets have separate license (see CREDITS.md)
