This is a classic Snake game built using Java and Swing. The game features smooth movement, food collection, and a score system. The goal is to eat food to grow while avoiding collisions with the snake’s own body. If you crash into yourself, it's Game Over!
✅ Smooth and responsive movement ✅ Collision detection with food and snake’s body ✅ Wrap-around mechanics for seamless movement across boundaries ✅ Score tracking ✅ Game restart functionality ✅ Simple and fun gameplay
- Java Development Kit (JDK) installed (Java 8 or later)
- An IDE like IntelliJ IDEA, Eclipse, or VS Code with Java support
- Clone this repository
- Open the project in your preferred Java IDE.
- Compile and run the
Main.javafile.
- Arrow Keys (⬆️⬇️⬅️➡️): Move the snake in the desired direction
- Restart Game: Press any key after Game Over
The game is developed using Java Swing and relies on KeyListeners for movement. The core logic includes:
- Snake movement with queued inputs for smooth direction changes
- Food placement at random locations
- Collision detection with walls and itself
- Score increment when eating food
- Game-over condition when colliding with itself
- Game restart when a key is pressed after losing
🔹 More advanced movement mechanics 🔹 Power-ups (e.g., speed boost, invincibility) 🔹 Improved UI with a main menu and settings 🔹 Sound effects and background music
