Skip to content

bablu456/Java-Snake-Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🐍 Classic Snake Game (Java)

A classic Snake Game built from scratch using Core Java (Swing & AWT). The goal of this project is to understand game loops, rendering, and event handling without using any external game engine.

🎮 Key Features

  • Smooth Controls: Lag-free snake movement using KeyAdapter.
  • Dynamic Speed Control:
    • Press 1: Slow Speed
    • Press 2: Normal Speed
    • Press 3: Fast Speed ⚡
  • Restart Mechanism: Press SPACE to restart instantly after Game Over.
  • Score System: Real-time score tracking.
  • Smart Rendering: Custom paintComponent rendering for smooth graphics.

🛠️ Tech Stack

  • Language: Java (JDK 17+)
  • GUI: Swing & AWT (JPanel, JFrame, Graphics)
  • Logic: OOPs, Multithreading (Timer), 2D Arrays, Event Handling

🚀 Roadmap & Progress

We successfully completed the project in 2 Days!

  • Day 1: Project Setup (JFrame, JPanel) & Grid Logic
  • Day 2: Snake Body & Movement Logic
  • Day 2: Food Generation & Collision Detection
  • Day 2: Score System & Game Over Screen
  • Day 2 (Bonus): Added Restart Functionality & Speed Controls

📸 Screenshots

Screenshot 2026-01-02 140903 Screenshot 2026-01-02 140923 ![img.png](img.png)

⚙️ How to Run

  1. Clone this repository.
  2. Open the folder in VS Code or IntelliJ IDEA.
  3. Run the Main.java file.
  4. Controls:
    • Arrow Keys to Move.
    • 1, 2, 3 to change speed.
    • SPACE to Restart.

👨‍💻 Author

Bablu Kumar - Aspiring Backend Developer

About

A classic Snake Game built using Core Java (Swing)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages