A polished Snake game built with Java Swing, featuring two game modes, smooth controls, dynamic difficulty, visual effects, and persistent high scores.
- Normal Mode with 5 progressive levels
- Endless Mode with edge wrapping
- Smooth Arrow Keys / WASD controls
- Pause, restart, win, and game-over screens
- Dynamic speed progression
- Separate high scores for each mode
- File-based score persistence
- Custom Java2D graphics and animations
- Clean OOP and event-driven architecture
| Action | Key |
|---|---|
| Move | Arrow Keys / WASD |
| Pause | P |
| Restart | R |
| Menu / Back | Esc |
- JDK 8 or newer
javac -d out src/*.javajava -cp out MainComplete 5 increasingly difficult levels. Walls and self-collision end the game.
Play continuously with edge wrapping and gradual speed increases. Only self-collision ends the run.
The project uses:
- Inheritance through
GameObjectandBasePanel - Polymorphism through custom
draw()implementations - Encapsulation for game state, score, and movement logic
- Abstraction for reusable UI and game components
- Event-driven programming with Swing timers, key bindings, and listeners
Main
└── GameFrame
├── MenuPanel
├── GamePanel
│ ├── Snake
│ ├── Food
│ └── ScoreManager
│ └── HighScoreManager
├── InstructionsPanel
├── GameOverPanel
└── WinPanel
Java Swing Java2D OOP Event-Driven Programming File I/O
Sound effects, power-ups, obstacles, themes, leaderboards, difficulty presets, and multiplayer.
Muneeb & Mustafa
Built as a Java OOP and GUI project.