Skip to content

A classic Snake game implemented in Java using Swing. Control the snake with arrow keys, eat apples to grow, and avoid collisions. Includes score tracking and a restart button. Ideal for learning game development and for fun.

License

Notifications You must be signed in to change notification settings

kumar-rakshith/Snake_Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sanke_Game

This repository contains the source code for a classic Snake game implemented in Java. The game is built using the Java Swing library for the graphical user interface.

Features

  • Classic Gameplay: Control the snake to eat apples and grow longer while avoiding collisions with the walls and the snake's own body.
  • User Controls: Use the arrow keys to control the direction of the snake.
  • Score Tracking: Keep track of the number of apples eaten.
  • Restart Button: Restart the game after a game over without restarting the application.

Getting Started

Prerequisites Java Development Kit (JDK) installed on your system. Running the Game

Clone the repository:

https://github.com/kumar-rakshith/Sanke_Game.git cd SANKE_GAME

Compile the Java files:

javac gamepanel.java sankemain.java gameframe.java

Run the game:

java SnakeGame

Files

  • gamePanel.java: Contains the main logic for the Snake game, including game initialization, rendering, and handling user inputs.
  • SankGame.java: The entry point for the game, which initializes the game window.
  • gameFrame.java: Sets up the main game window and adds the game panel to it.

How to Play

Use the arrow keys to change the direction of the snake. Eat the apples to grow longer. Avoid running into the walls or the snake's own body. The game ends when the snake collides with a wall or itself. Click the "Restart" button to play again after a game over.

Screenshots

Screenshot (165) Screenshot (164)

Contributing

Feel free to fork this repository and submit pull requests. Contributions are welcome!

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

A classic Snake game implemented in Java using Swing. Control the snake with arrow keys, eat apples to grow, and avoid collisions. Includes score tracking and a restart button. Ideal for learning game development and for fun.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages