Overview

Your first task is to choose a simple one-player, two-dimensional (2D) board game, and then implement the 'engine' of that game in Java. You should write some unit tests to check that your game logic works correctly.

You second task is to use JavaFX to add a graphical user interface (GUI) to your game, which displays the 2D board and allows the user to play the game. So you must keep the basic game idea fairly simple, and ensure that it is not too hard to add the GUI to it. You MUST use JavaFX, not any other Java GUI libraries.

The 'FullHouse' Game

You must implement the game called "FullHouse" from:

  • http://www.lutanho.net/stroke/online.html

This is a simple 2D puzzle game that uses a discrete 2D grid for the playing board. The game requires the player to move one blue piece around the board (using arrow keys or mouse clicks) to try and visit ALL the empty squares. To make the puzzles more challenging, the player can click at the beginning to choose a starting location. This game was invented in 2004 by Erich Friedman.

Hint: to solve Puzzle 1, try starting at position (2,2)?

Requirements

  • You should implement at least three levels of the puzzle.
  • You should allow the player to choose which level they want to play.
  • Your game should show a "Oops!. Try again?" message when the player is stuck. (Either as a popup Alert, or as a message on the main window).
  • Your game should keep track of the total time (NNN seconds) spent on each level and report that time when the user finally passes the level.
  • Your game should show a "You won in NNN seconds!" message when they succeed in passing the current level (visiting all empty cells).
  • You should use images to make the game look more visually interesting.

Part 1: Game Engine

1.Set up your Git Repository. When you click on the Blackboard link for this assignment, you will automatically create your own private GitHub repository containing two simple modules: boardgame_engine and boardgame-gui.

  • Clone this repository onto your computer using IntelliJ.
  • Make sure you also have Java JDK 11 installed on your computer.

2.Check you can run JavaFX. I have set up the boardgame-gui project to use the 'Gradle' build tool, which means that it should automatically download and install the necessary JavaFX and JUnit libraries when you build and run the project on each new computer. (You may see a popup message down the bottom of IntelliJ: "Gradle projects need to be imported". Click on "Enable Auto-Import" and IntelliJ will automatically download and install JavaFX for you! If IntelliJ asks you for the location of Gradle, you may need to turn off the "Use local gradle distribution" and select the alternative option: "Use gradle 'wrapper' task configuration" - this uses the gradle that is built into IntelliJ). Run the RunGame class to check that you can run the GUI it should show a simple GUI with a single button that says: "Amazing Board Game coming soon".

3.Data Design Decisions: Think carefully about whether each cell in your board should be a primitive value (like a boolean, an integer, or an enum value), or should it be an object? Using objects is more flexible, since it allows you to use Java subtyping to make different cells have different behaviour. But many of the games suggested above do not require the cells to have fancy behaviour, so a primitive value might be sufficient for your game.

4.Implement and Test Your Game Engine: I strongly suggest that you use TDD to develop your unit tests and game engine at the same time, in parallel. Recall: Write a test for each new feature and check that it fails, then implement that feature in your engine classes and rerun the test to check that it now passes. Repeat You can refactor (rename and reorganise) your code at any stage, if you see a way of making it simpler and more elegant. By the time you have finished implementing your game engine, one (or several) of your tests should be stepping through a complete game from start to end, calling the methods of your engine API and checking the results, including the game win/lose verdict at the end.

5.Class Relationships: To get high marks, your engine needs to include several Java classes, with some association/composition relationships between them, and if possible, some inheritance relationships. Think about where you can best use these Java features.

Part 2: Game GUI

The goal of this stage is to use JavaFX to add an elegant and fully functional GUI to your game so that it can more easily be played on desktop computers. Your GUI should have the following features:

  • event-handling of mouse and/or keyboard events;
  • display of bitmap images (I recommend you use some large images for the background of the whole game or each panel, so that the game looks professional and entertaining);
  • multiple panels, with a main gaming panel to display the game, plus one or more panels around the edges to display game options, score information, and control and help buttons etc.;
  • correct resize behaviour when the user adjusts the main window to different sizes for different devices;
  • a clean separation between the back-end (game engine) and front-end (GUI) classes using different Java package names, as described above;

Start by drawing one or two paper sketches of the GUI you plan to build. Take a photo of each sketch, as you will need to include these in your final report.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.