Skip to content

Latest commit

 

History

History
47 lines (38 loc) · 1.99 KB

README.md

File metadata and controls

47 lines (38 loc) · 1.99 KB

Snake Game

This is a simple desktop snake game written in Java and JavaFX. My very first JavaFX application :)

Rules of the Game

  • Use arrow keys to move the snake around the board.
  • Any attempt to move the snake in the opposite direction is ignored.
  • Food (apple) is generated at random positions. When the snake eats an apple, it grows longer. 1 point is also rewarded for each eaten apple.
  • For every 5 apples eaten, the snake moves a little faster.
  • There is a limit on how fast it can move, which is reflected by the indicator at the bottom of the board.
  • The game is over when the snake either runs off the board or runs into itself.

Look and Feel

Game in progress

Game In Progress

Game over

Game Over

Running the Application

Prerequisites

  • Java 15+
  • Maven 3.5.3+

Run via Maven

We can use JavaFX Maven plugin to run the application.

Once the project is downloaded onto your local system, go to the snake-game directory and run the following on command line:

    mvn --projects core clean install
    mvn --projects gui javafx:run

Create Runtime Image

We can also use the JavaFX Maven plugin to create a custom runtime image.

In the snake-game directory, run the following on command line:

    mvn --projects core clean install
    mvn --projects gui javafx:jlink

The runtime image can then be found in the gui/target/snake directory and the launcher (named snake.bat, for example, on Windows) is in gui/target/snake/bin.

Credits