This is a simple desktop snake game written in Java and JavaFX. My very first JavaFX application :)
- 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.
- Java 15+
- Maven 3.5.3+
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
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
.
- Sound effects from zapsplat
- Apple icon made by Smashicons from Flaticon
- Close button icon made by Catalin Fertu from Flaticon
- Snake and speed icons made by Freepik from Flaticon