Group no-59
Team Members:
- Samridh Gupta (2022441)
- Tanmay Singhal (2022535)
GitHub Repository: Stick Hero Game
- Extract the project from the zip file.
- Run the
Main.java
file in the Intellij IDE. - The code should now run.
Note: If you encounter any errors, download the JavaFX Media dependency and JUnit dependency.
- JavaFX-Media-18.01
- Junit 4
- Background Music
- Special Sound Effect on getting a cherry
- Lifetime cherry counter for better tracking of cherries
- Character Icon change on the main screen
- While moving, pressing Space will flip our character, allowing him to take the cherries that spawn.
- Hold the left mouse button to extend the stick to the required length.
- Advance further to get a higher score.
- Singleton: We use the singleton design pattern to generate an instance for the player, which is called using the
getPlayer()
function. - Decorator: We used the decorator design pattern within the scoreboard class. We have created a
Board
interface for which there exists anSBDecorator
class. ThisSBDecorator
class is extended byBlackSBDecorator
, which updates the text style of the scoreboard to black text and bold.
- First, the
GameTest
class is run, which runs the JUnit tests to check the initial conditions of the game. - In the main file, we use
launch(args)
to launch our code. - First, we call
setup
for setting up the initial elements of the game, such as the player, the stick, the platforms, etc. This method is also used whenever we successfully move ahead a platform to update the old platforms and score, and create new platforms. - Next, we check for input using
mousePressed
andmouseReleased
. While the mouse is held, the stick keeps extending. Within it rest other methods which check that the length of the stick is as per requirement. - We use
keyPressed
to flip the character during the movement on the stick. - We check for collisions with the cherry and the platform while the player is flipped. If the player hits a cherry, a sound is emitted and the cherry is collected.
- When the platform is hit, it takes the user to a game over screen. In this game over screen, there is an option to go back to the main menu and another for revive provided you have at least 2 cherries.
- If the length of the stick is less than the distance between the platforms or larger than the second platform's width, the user is taken to the same game over screen.
- The high score and last score are serialized into files so that progress can be restored later. A counter for lifetime cherries is also maintained, which is serialized as well.
- Whenever the game starts, the scores are deserialized from the file to show the last score, the high score, and the lifetime cherries.