Skip to content

ElanaBiaSabu/Snake-Game--Java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Snake Game (Java)

A simple console-based Snake game built using core Java.

Features

  • Snake movement using dx, dy logic
  • Collision detection (walls + self)
  • Food generation
  • Snake growth using ArrayList
  • Game loop implementation

What I learned

  • Core Java fundamentals
  • Game logic thinking
  • Coordinate system handling
  • Data structures (ArrayList)

Note

This project was built as a learning exercise with guidance (including AI) to better understand programming concepts.

Game Logic

The Snake Game is based on simple movement and collision rules.

🎮 Movement System

The snake moves continuously in one direction based on user input:

  • U (Up)
  • D (Down)
  • L (Left)
  • R (Right)

The direction changes only when a new valid key is pressed.


Game Over Conditions

The game ends in two cases: 1.Wall Collision If the snake crosses the boundary of the game area, the game is over.

            2. Self Collision

If the snake’s head touches any part of its own body, the game ends immediately.


###Food System

  • Food appears at random positions
  • When eaten:
    • Snake grows longer
    • Score increases

About

Console based Snake game built using Java

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages