Breakout Game Development: JavaFX Implementation with Scoring & Sounds

Verified

Added on  2019/09/19

|2
|885
|200
Project
AI Summary
This project requires the implementation of a Breakout/Arkanoid game using JavaFX. The assignment involves recreating the game with specific features, including ball movement, paddle control, and block destruction. The project must adhere to the provided class diagram and incorporate constants defined in the Constants interface. Key functionalities include bouncing the ball off blocks, changing the ball's horizontal velocity based on paddle contact, scoring, refreshing the board after all blocks are hit, adding lives, replay functionality, and a start prompt. Sound effects for ball-block, paddle, and wall collisions are also required. The solution should be submitted as a zipped project directory. This project aims to help students understand game development and JavaFX programming, and Desklib provides additional resources such as past papers and solved assignments to aid in the learning process.
Document Page
Project 7
You will implement a version of Breakout/Arkanoid using JavaFX.
Requirements
Download the BreakoutStarter.zip starter project zip file. Unzip it and open it in IntelliJ.
1. Have fun!
2. Your functionality will match that in shown in the demo, except for the extra credit noted below if
you decide to attempt that.
3. Implement the design shown in the class_diagram.uxf file included in the project directory.
Recall you can open that in Umlet (Links to an external site.)Links to an external site. or (online)
in Umletino (Links to an external site.)Links to an external site.. You may add additional classes
and/or methods. For instance, I have a private helper method in my Breakout class
called updateBall that call's the Ball's move method and checks for collisions against the
other parts. Another example is the ballHitBlocks method which first checks to see if a ball
hits one or more of the blocks, noting which part of the block the ball hit (HINT:
uses whichPartHit ) and then sets one or more flags on whether to bounce vertically and/or
horizontally. Then after that pass through all the blocks, it removes the blocks both from the root
of the scene graph as well as the collection of blocks.
4. On the class diagram you will notice on the "has a" link between Breakout and Block an
asterisk, which means that Breakout has 0 or more blocks. The way that is implemented is
using some sort of collection, e.g. array, 2d-array, or something in the java.util . package.
HINT: In my implementation I use a java.util.ArrayList<Block> .. This is helpful
especially because when it comes time to remove any blocks hit by the ball (on a
given KeyFrame update) you can use the removeIf method that takes a lambda.
5. You should have no magic numbers in your code (except if you need to divide by 2). Your code
should be written making use of the constants defined in the Constants interface.
6. Having the ball bounce off the blocks. First note that it is possible for the ball to hit up to 3 blocks
at a time. The way the ball bounces off, depends on which part of the brick the ball hit. If the ball
hit the left or right side of the block then you flip the horizontal velocity. If the ball hit the top or
bottom of the block, you flip the vertical velocity. If the ball hit the corner of a block, you flip both.
Of course, if you hit multiple blocks in different places then you will need to change the direction
accordingly. The good news is that the logic for determining where the ball hit a particular block
is given to you in the method whichPartHit . Notice it returns an enum, BlockSide . This
tutorial (http://tutorials.jenkov.com/java/enums.html (Links to an external site.)Links to an
external site.) should give you an idea of how to use an enum.
7. Bouncing off the paddle, can change the ball's horizontal velocity. Basically, you subtract the
middle horizontal point of the paddle from the middle point of the ball and then scale (divide) that
result down and set it as the new horizontal velocity of the ball. Make sure to scale it enough so
that the horizontal velocity does not end up too fast.
8. Like shown in the demo video, you must provide the instance
variables _bounceBottom and _testTop . When _bounceBottom is true, the ball will bounce
off the bottom of the screen instead of falling through and causing the game to end -- this will
make it easier for the TA during grading. When _testTop is true, the ball will start out above
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
the bank of blocks -- again, this will help the TA check that your code (especially for bouncing) is
working properly.
9. Note that the Block class has overridden setX and setY methods -- they
add Constants.BLOCK_BORDER to the x and y component respectively.
Other Components Needed
2 points - scoring (must be displayed)
2 points - refreshing the board when all the blocks have been hit
2 points - adding lives (must be displayed)
2 points - adding ability to replay the game after it has been lost
2 points - adding requirement to hit key or click mouse button to start (must show a label saying
what to hit to start, and that label must be removed once started)
2 points - adding pause/unpause functions (when paused, must show a label denoting that the
game is paused, label must be removed once unpaused)
3 points - adding different sound effects for ball hitting blocks, paddle, walls
What to Submit
Zip your Breakout project directory into a zip file named Breakout.zip and submit as an attachment.
chevron_up_icon
1 out of 2
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]