Reference no: EM133151969
ICT221 Java Programming Assignment
Your solution must be clearly separated into two separate parts, in separate Java packages:
Part 1: (in packagesavekoalas.engine): your Game Engineclasses with Unit Tests.
Part 2: (in packagesavekoalas.gui): a JavaFX GUI that allows users to play your game.
After you create the project in GitHub classroom, two packages will be created automatically. Please keep that code structure unchanged.
SaveKoalas Game Description
SaveKoalasis a 2D gamein a 10 x 10 grid maze map.Unfortunately, because of bushfire, the map will be in fire after a time limit. The goal is to move the player to save all koalas in the map and leave the map at the exit door within the time limit.
To simplify the design, we assume each movement, or a step, of the play equals to one time unit. The maze map consists ofthe following items:
• An entrance to the maze, which is located at the bottom left grid.
• An exit of the maze, which is located at the top right grid.
• Aplayer, who is place at the entrance at the beginning of a game.
• 5koalas, each of which is placed at a random grid.
• Some traps, each of which is placed at a random grid. Once in a trap, the player needs to use10 stepsto move out of the trap.
• Some magic fountains, each of which is placed at a random grid.Visiting/consuminga fountaincan increasetime limit by 6.
The followings are its key features and settings.
• Tostart a new game:
1. The player input an integer d, the difficulty level of the game. dshould be in the range of 0 - 10, and it has the default value of 5.
2. The player clicks a "Run" button to start the game, which triggers the random generation of the map.
• Random generation of the map:
1. An entrance cell is placed at the bottom left cell.
2. An exit cell is placed at the top right cell.
3. A time limit, which is initially set up as 200 steps.
4. The player will appear in the entrance cell with the step counter as "0".
5. 5koalasareplaced randomly in the map.
6. d traps are placed randomly in the map.
7. (10 - d) fountains are placed randomly in the map.
8. The entrance, exit, koalas, traps, and fountains should not overlap.
• To play a game:
1. The player can move in 4 directions: left, right, up, and down inside the map.Each movement is considered as 1 step,unless stated otherwise.
2. Moving out of a trap uses 10steps.The trap remains there after the visit.
3. Visiting a fountain increases the time limit by 6.After the visit, the fountain is consumed, and the cell becomes empty.
4. Visiting a koalasaves1koala. The koala is picked up, and the cell becomes empty.
5. The game finishes when
• (Win) The player saves all 5 koalas and is at the exit cell. The score is: (time limit - steps of the player).
• (Lose) The time limit has reached. The score is -1.
6. The score is shown at the end of a game.
• Other requirements:
» The game can be played in the text UI in which the interaction is enabled by typing keywords, e.g. "u" for up and "d" for down.
» In the game, different items should be displayed with different icons/symbols.
» Time limit of the map is displayed and updated during the play.
» Steps of the player is displayed and updated during the play.
» The number of saved koalas is displayed and updated during the play.
» In the GUI, a player can play by clicking 4 control buttons.
» In the GUI, a "Help" button to get instructions on the game play.
» In the GUI, a "Save" button to save the game play as a .txt file.
» In the GUI, a "Load" button to load a saved game.
It is recommended that you implement the 'engine' ofthe game first. You should writesome unit tests to check that your game logic works correctly.
Then you can 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. You MUST use JavaFX, not any other Java GUI libraries.Otherwise, the GUI part will be marked as 0.
Learning Objectives
1. Learn to use object-oriented design (OOD) to design Java programs;
2. Be able to use inheritance/interface and subtyping relationships between classes;
3. Be able to use association or composition relationships between classes;
4. Be able to develop a comprehensive suite of unit tests for the core logic classes of an application (e.g., for the game engine);
5. Build simple graphical user interfaces using JavaFX.
Part 1: Game Engine
1. Set up your GitRepository.Follow the assessment link in Github Classroom to automatically create your own private GitHub repository containing one module with two packages: savekoalas.engine and savekoalas.gui.
a. Clone this repository onto your computer using IntelliJ.
b. Make sure you also have Java JDK 15or later installed on your computer.
2. Check you canrun JavaFX.This project uses the 'Gradle' build tool to automatically download and install the necessary JavaFX and JUnit libraries when you build and run the project.
After the build is complete, right-click on "src/main/java/savekoalas/gui/RunGame" and do "Run RunGame.main()". You should see a blank JavaFX GUI pop up.Use this RunGame class every time you want to run your GUI.
3. Data Design Decisions:Think carefully about whether each cell in your map should be a primitive value (like 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.
4. Implement and Test Your Game Engine:GameEngine.java is provided as the base for engine development. You need to add more details to it, and you may also want to add other class files in the "savekoalas.engine" package to support the engine development. TDD is recommended, but not necessary, 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. Text-based play: The main() method of GameEngine class should support a text-based game play in the console.
6. 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/interfaceusage. Think about where you can best use these Java features.
Part 2: Game GUI
The goal of this stageis 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 GUIshould have the following features:
• event-handling of mouse events, including buttons for starting game and moving up/down/left/right;
• display of bitmap images (I recommend you use some large images for the background of the whole game, and use some small images for different items/cells in the map, 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.;
• a clean separation between theback-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.
Attachment:- Java Programming Assignment.rar