Skip to content

Latest commit

ย 

History

History
95 lines (66 loc) ยท 2.23 KB

File metadata and controls

95 lines (66 loc) ยท 2.23 KB

๐Ÿ Snake Game (Java)

This is a simple and fun version of the classic Snake game developed using Java Swing. The game is controlled with arrow keys and includes a basic scoring system.

๐ŸŽฎ Screenshot

The game screen displays the snake, food (apples), and current score at the top.

๐Ÿš€ Getting Started

Requirements

  • Java JDK 8 or later
  • Any Java IDE (e.g., IntelliJ IDEA, Eclipse, VS Code) or terminal
  • javac and java must be available in your system PATH

Compile and Run

1. Compile

javac -d bin src/SnakePackage/*.java

2. Run

java -cp bin SnakePackage.SnakeGame

๐Ÿ–ฅ๏ธ Alternative: Run the .exe File

You can run the game directly on Windows using the included Snake.exe file.
Use Snake_Setup.exe (created with Inno Setup) to install the game.


๐ŸŽฎ Game Rules

  • You start as a snake with 6 body parts.
  • Red circles represent apples.
  • Every time you eat an apple:
    • The snake grows longer
    • Your score increases
  • The game ends if you hit the wall or collide with your own body.
  • After a game over, press Enter to restart.

โŒจ๏ธ Controls

Key Action
โฌ…๏ธ Left Move left
โžก๏ธ Right Move right
โฌ†๏ธ Up Move up
โฌ‡๏ธ Down Move down
โŽ Enter Restart the game

๐Ÿ“ Project Structure

SnakeProject/
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ SnakePackage/
โ”‚       โ”œโ”€โ”€ SnakeGame.java
โ”‚       โ”œโ”€โ”€ GameFrame.java
โ”‚       โ””โ”€โ”€ GamePanel.java
โ”œโ”€โ”€ bin/                     # Compiled classes (via javac -d)
โ”œโ”€โ”€ screenshot.png           # Game screenshot (optional)
โ”œโ”€โ”€ Snake.exe                # Executable file (from Inno Setup)
โ”œโ”€โ”€ Snake_Setup.exe          # Installer (optional)
โ””โ”€โ”€ README.md

๐Ÿ› ๏ธ Technologies Used

  • Java 8+
  • Java Swing (for GUI)
  • Inno Setup (for Windows installer)

๐Ÿ“„ License

This project is licensed under the MIT License โ€“ see the LICENSE file for details.


Enjoy the game! ๐Ÿ•น๏ธ