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.
- 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
- Use arrow keys to control the snake's direction.
- Press SPACE to pause or resume the game.
- Press R to restart the game after collision.
- Java Development Kit (JDK) 8 or higher
- JavaFX library
- Compile the source code:
javac Main.java
- Run the compiled code:
java Main
- 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