Skip to content

A basic Snake Game that was built in Java with AWT (Abstract Window Toolkit) and Swing (GUI Toolkit) using Eclipse.

License

Notifications You must be signed in to change notification settings

Talha-Tahir2001/Snake-Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Snake Game in Java (using Swing and AWT)

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.

How to Play

  1. Ensure you have Java Runtime Environment (JRE) installed on your computer.

  2. Download or obtain the JAR file of the Snake Game.

  3. Open a terminal or command prompt and navigate to the directory where the JAR file is located.

  4. Run the JAR file using the following command or by double clicking on .Jar file:

    java -jar SnakeGame.jar

  5. The Snake Game window will open, and you can start playing using the arrow keys to control the snake's direction.

  6. Try to collect as much food as you can without colliding with the boundaries or the snake itself.

Game Controls

  • 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.

Game Rules

  1. The snake moves continuously in the direction it is facing.
  2. When the snake collides with the boundary of the game window or its own body, the game ends.
  3. The game score increases as the snake collects food items.
  4. The snake's length grows after eating each food item.
  5. New food items appear at random positions on the game board.

Customize the Game

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!

Credits

This Snake Game implementation is based on Java Swing and AWT libraries.

License

This project is licensed under the MIT License.

About

A basic Snake Game that was built in Java with AWT (Abstract Window Toolkit) and Swing (GUI Toolkit) using Eclipse.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages