Skip to content

A simple implementation of the classic Snake game using Java's AWT and Swing libraries. The game allows the player to control the snake using arrow keys, eat food to grow, and avoid colliding with the walls or its own body. The score is displayed based on the number of tiles the snake has eaten.

Notifications You must be signed in to change notification settings

anujayavidmal2002/Snake_Game_Using_java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Snake Game Using Java

This project is a classic Snake game implemented in Java using Swing for the GUI. It is a fun, interactive, and beginner-friendly project showcasing the use of Java's AWT and Swing libraries.

Features

  • Dynamic Gameplay: The snake grows longer as it consumes food.
  • Collision Detection: The game ends if the snake collides with itself or the walls.
  • Score Display: The player's score is displayed on the screen during gameplay.
  • Smooth Animations: The game runs smoothly at a consistent speed using a timer.

How to Run the Game

1.Clone the repository:

git clone https://github.com/anujayavidmal2002/Snake_game_Using_java.git

2.Open the project in your preferred IDE (e.g., IntelliJ IDEA, Eclipse, or NetBeans).

3.Compile and run the Main.java file.

4.Use the arrow keys to control the snake:

  - Up Arrow: Move up
  - Down Arrow: Move down
  - Right Arrow: Move right
  - Left Arrow: Move left

5.Enjoy the game! 🎮

Gameplay Rules

  • Objective: Control the snake and collect food to grow longer.
  • Game Over:
    • When the snake hits the walls.
    • When the snake collides with its body.
  • Your score is equal to the length of the snake.

Technologies Used

  • Java
    • Swing
    • AWT (Abstract Window Toolkit)
  • Object-Oriented Programming (OOP) principles.

Future Improvements

  • Add levels with increasing difficulty.
  • Implement a high-score system.
  • Introduce obstacles on the board.
  • Add a pause and restart feature.

About

A simple implementation of the classic Snake game using Java's AWT and Swing libraries. The game allows the player to control the snake using arrow keys, eat food to grow, and avoid colliding with the walls or its own body. The score is displayed based on the number of tiles the snake has eaten.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages