Skip to content

ro-drick/SnakeGame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Snake Game

Description:

This is an implementation of a simple snake game using JavaFX. The game features a snake controlled by the user, which moves around a grid to eat food. As the snake eats food, it grows longer. The game ends if the snake collides with itself. Users can control the snake's direction using arrow keys and pause/resume the game using the space bar.

Features:

  • Snake movement controlled by arrow keys (UP, DOWN, LEFT, RIGHT)
  • Pause/resume functionality (SPACE key)
  • Game restart on collision (R key)
  • Randomly generated food on the grid
  • Collision detection with snake body segments
  • Smooth animation using JavaFX Timeline and AnimationTimer

How to Play:

  1. Use arrow keys to control the snake's direction.
  2. Press SPACE to pause or resume the game.
  3. Press R to restart the game after collision.

Requirements:

  • Java Development Kit (JDK) 8 or higher
  • JavaFX library

Running the Application:

  1. Compile the source code: javac Main.java
  2. Run the compiled code: java Main

Controls:

  • UP arrow key: Move snake upwards
  • DOWN arrow key: Move snake downwards
  • LEFT arrow key: Move snake leftwards
  • RIGHT arrow key: Move snake rightwards
  • SPACE bar: Pause/resume game
  • R key: Restart the game after collision

About

Old school snake game

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published