Brick Breaker is a classic arcade game implemented in Java using JavaFX for the graphical user interface. The game is designed to entertain and challenge players by allowing them to control a paddle and a ball to break bricks on the screen. It provides a fun and nostalgic gaming experience, reminiscent of the popular brick-breaking games of the past. The project utilizes Java 11.0.2, Eclipse IDE, JavaFX for the GUI components, and Maven for dependency management. It incorporates refactoring, code maintenance, design patterns, and documentation practices to improve code quality and maintainability.
I'm using Java 11.0.2 on eclipse.
$user > java --version
openjdk 11.0.2 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
I have tested my program on 2 different Windows devices using Eclipse
To run the game, select Run -> Run Configurations -> Arguments ->
Add the following line to the VM Arguments:
--module-path "/path/to/JavaFX/lib" --add-modules=javafx.controls
In my case, the path to my JavaFx library is as follow:
--module-path "C:\javafx\javafx-sdk-17.0.1\lib" --add-modules=javafx.controls
After that, run
- Maven Build (goal: "verify")
- Maven Clean
- Maven Install
Once the Maven Dependencies folder appeared, the program is now ready to be run.
Now, right click the main project and run it as a Java Application.
If any error occured, try right click the project -> maven -> reload project.
Game Starts
- Organized classes into packages
- Basic Code Maintenance
- Renamed Variable & Class name to improve readability
- Improved encapsulation
- Added Interfaces (Playable interface)
- broke down large classes (wall & gameboard class is too large)
- Error Handling (Throws exception, print error message)
- Removed code smells
- removed duplicated code
- removed primitive obsession, used enum instead (enum CrackDirection, enum Impact Direction, enum BrickType)
- Separated Crack Class into its own individual class to adhere the Single Responsibility principle
- Did not allow crack class to inherit from brick class due to Liskov's Substitution Principle
- Arranged Code into MVC pattern
- brick
- ball
- player
- wall
- crack
- Applied some design patterns
- Level Factory
- Brick Factory
- Ball Factory
- Added Singleton to Player Class
- Added meaningful JUnit tests, testing for the void methods for each class
- BrickTest
- BallTest
- WallTest
- PlayerTest
- CrackTest
- LevelTest
- Converted the project to Maven project to handle dependencies (JUnit & JavaFx)
- Added Highscore
- Able to save and load the highscore from a txt file
- When the current score of the player is greater than the highscore, it overwrites the highscore
-
Added additional levels
- The presence of special brick when creating a single brick type level
- From 4 levels -> 8 levels
- New brick type: Vibranium Brick, stronger than steel brick (able to crack)
- When creating single type brick level, there's chance to spawn health brick and special brick, when creating chessboard type level, there's 10% chance to spawn health brick
-
Additional Features
- Cheatmode enabled when special brick is destroyed
- 2 types of cheatmode
- 30% chance it increases the speed of the ball
- 70% chance the ball bounces oddly after impact
- Added Username input
- Added health bricks
- Add health when health brick is destroyed
- Additional Info Page created using Java Swing
- Added choice to choose level in Debug Panel
- Created a main menu using JavaFx
- Javadocs
- High-level class diagram:
- Readme
- commit history from the start of the project
- meaningful commit messages
- use of branch and merge function