Second homework of the cc3002 course dictated in Universidad de Chile, consisting in the creation of the logic and rules for a functioning virtual pinball game in java.
The project implements the following specifications:
-
The main executable class is
Main, which launches the app when executed. -
The game code inside the
logicpackage describes all game interacting elements so far. -
In
logic.bonusthe bonus events are implemented, which are special events the game triggers under certain conditions. These bonus objects must extend theAbstractBonusabstract class, and implement abonusBehaviourmethod, detailing the bonus's effects, this method will later be called using the template design pattern. -
In
logic.utilssome utility classes and interfaces are implemented. This is where theVisitableGameElementandGameElementVisitorinterfaces are located, which detail the expected behaviour of the visitor pattern, occupied byGameto interact with it's elements. -
In
logic.gameelementsthe game's interacting elements are implemented. Here is where bothBumpers andTargets are. All game elements that are hittable by the ball must extend theAbstractHittableabstract class and can choose to implement thebeforeHitBehaviourand/or theafterHitBehaviourmethods to specify their own changes on hit, which are too called using the template pattern. These game elements also must implement theacceptmethod coming from the previously mentionedVisitableGameElementinterface, and therefore detail what their effects on theGameare when hit. TheHitVisitorelement implements how this interactions are managed. -
A
Bumperis an object that can be hit by the ball, and give a score to the player, furthermore, once hit a certain number of times it 'upgrades' giving a bigger score on hit. All bumpers must extend theAbstractBumperabstract class, and detail their respective scores and hit-counters for upgrading, also implementing theacceptmethod. -
A
Targetis a hittable object too, that may or may not give a score on hit. Once hit it deactivates, and has a chance of triggering aBonus. All targets must extend theAbstractTargetabstract class, and detail their respective scores, also implementing theacceptmethod. -
In
logic.tablethe game'sTableobjects are implemented. These tables serve as containers, generators and managers of game elements for theGameclass. All tables must extend theAbstractTableclass and implement a proper constructor method that ensures their inner objects are created accordingly. -
In
controllertheGameclass can be found. This object acts as the game's controller and describes all interactions of it's elements either directly or through theTableobject it can instance. -
In
facadethe classHomeworkTwoFacadecan be found, which implements the facade design pattern, serving as a demonstrator of the game's workings. This class should be used when asserting it's correct implementations. -
The game code inside the
guipackage describes all game view classes and methods. -
In
guithe classPinballGameApplicationcan be found. This class sets up the game's view and manages FXGL entities and their interactions. -
Inside of
gui.FXGLentitiesis where the classPinballEntityFactory, it has the job of storing methods that create entities for the game. -
In
gui.FXGLentities.components,gui.FXGLentities.eventsandgui.FXGLentities.statesthe classes governing the permanent behaviour of entities, the game's events, and the classes governing transitory behaviour of entities can be found, respectively. -
The game's view uses, in
PinballGameApplication,PinballEntityFactoryto generate entities for the screen, classes ingui.FXGLentities.componentsto give them special properties,gui.FXGLentities.statesto add virtual state machine functionality to them, andgui.FXGLentities.eventsto communicate important context information between distant parts of the app.
The only necessary variables for generating the figures on screen are the position and primitives generating an object, and so FXGL takes care of managing the cycle.
The Pinball game implements the following interactions:
-
Inside the running app the
Nkey restarts the game, positioning hittable elements for the ball randomly in the game's board -
The
SPACEkey throws a new ball into the board, as long as there was not one inside beforehand. -
The
AandDkeys activate the left and right flippers respectively.
As for specific features "outside of the core game":
-
Whenever a bumper upgrades it resets after 10 seconds, a dropped spot target resets after 20 seconds and a dropped drop target resets after 120 seconds.
-
Manual testing is enabled by default, the ball will show a highlighted colour whenever the mouse is in a position that could "click it", clicking then makes the ball a fully drag and drop object on the board.
-
Both flippers activate from the use of different keys, as mentioned beforehand.
-
Whenever a hittable gets hit in the board, an explotion of stars is produced.
Getting a copy of this project is easy, the next few steps need to be followed:
- Install Git on your local system.
- Open git bash in the directory where you wish to save the project's copy.
- Use the
git clone https://github.com/Gedoix/cc3002-pinball.gitcommand to download the project's source files onto a newcc3002-pinballfolder in the directory.
- Only Git is necessary for downloading the software. Install instructions for git can be found here
- The latest java JDK should be installed, otherwise there's no way to run the software.
- A java IDE is recommended for running automated tests for the project. The recommended IDE (the one used to make this) is JetBrain's IntelliJ Idea IDE.
Once the project has been downloaded, follow these next steps to get it running in your favorite IDE:
- Find and select the
Import Projectoption in your IDE. - Make sure to configure the import to expect a Maven project structure.
- Find and select your new
cc3002-pinballdirectory as the project's root. - Name the project as you please.
- If you're using the recommended IntelliJ IDE, allow it to overwrite the existing
.ideafolder. - And you're done!
All source files for the project can be found in the cc3002-pinball/src/main/java/ directory, while the test sources
can be found inside cc3002-pinball/src/test/java/.
Now that the project is be loaded into your IDE, find and select the Run all tests with coverage option to run
all the automated testing cases for the project. This option can be easily be found in IntelliJ by right-clicking the
project root directory.
Tests Passed: 54 of 54 tests
Or a similar message should be displayed on your IDE, meaning the project is configured accordingly.
After all has been checked, just find and run the Main.main() method by right clicking on it and selecting run, and
so the game can be played.
A window with the interactable app should open.
- JetBrain's IntelliJ Idea - The IDE used
- Maven - Dependency Management
- ShareLatex - PDF creation
- FXGL - Game making framework used for view and it's interactions
I used GitHub for versioning. For the versions available, see the tags on this repository.
- Diego Ortego Prieto - Implementation and testing - Gedoix
- Juan-Pablo Silva - Initial project structure template - juanpablos
- Almas Baimagambetov - FXGL Framework - AlmasB
- Bensound.com - Background jazz song - Bensound
See also the list of contributors who participated in this project.
- Hat tip to Stack Overflow for being awesome.
- A Markdown Cheat-sheet and a proper README.md template were used, credit of which goes to their respective creators.
- A JetBrains .gitignore file was also used for this project's versioning, credit of which goes to it's respective creator too.