A2: Event Loops and Drawing (Java) -- Mini Game

Check here for the new sound package. Unless it's still not working, here are the sounds in wav format.


You will have to implement a simple beat'em up inspired from One Finger Death Punch in JavaFX. The players are at the center of the screen and cannot move. They have to get rid of waves of enemies coming from the left and right sides of the screen.

The player use the left and right arrows to fire fireballs.

We've also made our own version that matches most of the assignment specification. Here's a video for reference, and screen shots are below. Your game should closely resemble this if not better.

Title screen

Game screen


  1. Learn how to build an interactive application in Java.
  2. Use JavaFX to handle drawing and animation of simple graphics.
  3. Provide visual and audial feedback, and gameplay elements to make the game more enjoyable.


Starting the Game

When launched, you should display a title screen including (at a minimum):

  1. The title of the game, at the top of the screen,
  2. Your name and student number, somewhere on screen,
  3. Directions on how to play the game (e.g. "Use left/right arrows to fire. Press ENTER to start the game, or Q to Quit").

The player should be able to start or quit the game from this screen. The player should also be able to quit the game from the game over screen.

When the game starts, it should resemble the screenshot above, with standard gameplay elements:

  1. a game screen, including the player at the center of the screen,
  2. a player-controlled avatar that can turn to the left and right,
  3. a indicator of the remaining enemies to come in the level,
  4. a score indicator, and
  5. an indicator of the remaining lives.

Status information (score, lives, remaining monsters) should be visible during gameplay, without obscuring the board.

The Monsters

The enemies monsters move individually at a constant velocity from the left or right side to the center of the sceen. They initially move from their starting position towards the player. When they reach the player the following happens:

  1. The player loses a life and dies if no lives are remaining,
  2. The enemy that touched the player makes a "step" back with an animation (whatever animation but an animation) and resume its course,

The enemies should spawn in some kind of a balance manner between left and right side.

Every time the player kills a monster, the score increases but if one fire ball does not kill a monster it's a miss and the score decreases.

One fireball can only kill one enemy!

The Player

The player has three lives at the start of the game: If the player has is touched by a monster, you remove one life. If they don't have anymore lives, then they lose the game.


The player interacts with the game by firing fireballs using the left and right arrow keys of the keyboard. There is no maximum fireballs. The fireballs are visible for a perios of time and disappear after the period of time. If they disappear before killing an enemy, the player loses one point.


The level continues until either all of the monsters are killed, or all of the player's lives are used. If all of the monsters are killed successfully, a congrats message is prompt to either continue to next level or quit. Subsequent levels all have the same layout, but the monsters move faster and the fireball has a lower lifetime than previous levels. There does not need to be any other visual changes.

You must have a minimum of three levels, and pressing "1", "2" or "3" from the start screen will launch the game at that level (this is not normal gameplay, but makes it easier for the TA to grade it!).

If the player succeeds in clearing all three levels, you should show a message telling them that they have won the game and display their score. You should prompt them to go restart the game (from level 1) or quit the game.

If the players dies, you should display a game over screen that includes a message telling them that they have lost the game, along with their score. You should prompt them to restart the game (from level 1) or quit the app.

Game Features

Your game screen should be no larger than 1280x640pixels. Your game window should NOT be resizable (i.e. you should prevent users from resizing it).

Your game should use audio feedback/sounds for key game elements (e.g when the player fires, when an monster is killed).

You should use images to represent the game elements: you can overlay images directly over Nodes.

You have a number of choices for sound and image assets.

UPDATE: here is the fixed sound package.


Here are some suggestions to get you started.

Since it's your fisrt project using JavaFX, don't forget to configure it by adding the JavaFX library to the project and to add the following VM option in the _Edit Run Configuration_ window to run your project: --module-path ${JAVA_FX_HOME}/lib --add-modules javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.web

Technical Requirements


Your directory structure for your assignment submission should be in subdirectories under your a2/ directory in your Git repository. It should use a standard file layout for an IntelliJ project. For example, it could resemble this (with possibly different and additional classes, image and sound file names of course).

        ├── .idea
        ├── a2.iml
        ├── out/
        ├── readme.md
        └── src/
            └── ressources
                └── sounds/
                └── images/
            ├── Sprite.java
            ├── Enemy.java
            ├── Player.java
            ├── Level.java
            └── MiniGame.java

Your submission needs to include:

Your `readme.md' file needs to include, at a minimum:

For example:

        Jeff Avery
        12345678 j2avery
        openjdk version "11.0.2" 2019-04-16
        macOS 10.14.6 (MacBook Pro 2017)
        * Used sound and image files distributed in-class.
        * No changes from specification.


Your submission will be assessed roughly as follows:

Complete submission. Code compiles and runs. Attribution in README file.
When the application is launched, the game displays a Start screen containing required information and instructions for the user. The user can launch or quit the game from this screen.
When the user starts the game from the Start screen, the game screen displays all required elements (lives, scoes, number of remaining enemies for the level, game screen with enemies and player).
Enemies spawn on either side of the game window. They move across the screen towards the player at the center at constant speed.
When they thouch the player take an animated step back and continue.
Player fires fireballs that die after a certain period of time. Fireballs that dies out decrease the score, fireballs that kill enemy increase the score.
When the level is cleared, the game progresses to a new level with faster enemies and reduced lifetime for fireballs. There are at least three levels (and 1/2/3 from the Start screen will launch them).
When the game ends, the appropriate message will be displayed (i.e. "you win" or "you lose") and the player will be prompted to restart or quit the game.
Compelling gameplay that includes graphics and sound effects!