This is a simple Snake game implemented in Java using Swing. The game window is a grid where the snake moves around. The objective is to eat the red apples that randomly appear on the grid, which causes the snake to grow longer. The game ends if the snake collides with itself or the boundaries of the grid.
- Use the arrow keys (up, down, left, right) to control the direction of the snake.
- The snake will continuously move in the direction it is facing.
- The game ends if the snake collides with itself or the boundaries of the grid.
- Press 'R' to restart the game after it ends.
- Up Arrow: Move the snake upwards.
- Down Arrow: Move the snake downwards.
- Left Arrow: Move the snake to the left.
- Right Arrow: Move the snake to the right.
- R: Restart the game after it ends.
- Responsive keyboard controls.
- Simple graphics using basic shapes.
- Game over message with option to restart.
This game project demonstrates basic game development concepts in Java, including graphics rendering, user input handling, game logic, and event-driven programming.
- Make sure you have Java installed on your system.
- Compile the
SnakeGame.java
file usingjavac SnakeGame.java
. - Run the compiled Java file using
java SnakeGame
.
Enjoy playing the Snake game! If you encounter any issues or have feedback, feel free to open an issue or submit a pull request.