This is a simple Snake Game implemented in Java using Swing and AWT libraries. The game consists of two classes: Snake.java
and Board.java
, which work together to create the game functionality. The objective is to control a snake and collect food items to grow longer while avoiding collisions with the boundaries of the game window and the snake's own body.
-
Ensure you have Java Runtime Environment (JRE) installed on your computer.
-
Download or obtain the JAR file of the Snake Game.
-
Open a terminal or command prompt and navigate to the directory where the JAR file is located.
-
Run the JAR file using the following command or by double clicking on .Jar file:
java -jar SnakeGame.jar
-
The Snake Game window will open, and you can start playing using the arrow keys to control the snake's direction.
-
Try to collect as much food as you can without colliding with the boundaries or the snake itself.
- Use the Up Arrow key to move the snake upwards.
- Use the Down Arrow key to move the snake downwards.
- Use the Left Arrow key to move the snake to the left.
- Use the Right Arrow key to move the snake to the right.
- The snake moves continuously in the direction it is facing.
- When the snake collides with the boundary of the game window or its own body, the game ends.
- The game score increases as the snake collects food items.
- The snake's length grows after eating each food item.
- New food items appear at random positions on the game board.
If you are interested in modifying or extending the game, you can make changes to the Snake.java
and Board.java
classes. Some possible enhancements could include:
- Changing the size of the game board.
- Adjusting the speed of the snake.
- Adding sound effects or background music.
- Implementing different levels of difficulty.
- Adding obstacles or power-ups.
Feel free to explore and experiment with the code to create your own version of the Snake Game!
This Snake Game implementation is based on Java Swing and AWT libraries.
This project is licensed under the MIT License.