SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 304 Weeks Ago, 5 Days Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 13 Dec 2017 My Price 8.00

For instance, I have a private helper method

I need help with an assignment that creates a game, that has a paddle and a ball. The ball will bounce off the paddle or walls and can hit the blocks. If it hits the blocks, they disappear. 

 

These are notes provided by the instructor:

 

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.

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 (Links to an external site.)Links to an external site. package. HINT: In my implementation I use a java.util.ArrayList<Block> (Links to an external site.)Links to an external site.. 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 (Links to an external site.)Links to an external site. method that takes a lambda.

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.

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.

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.

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 the bank of blocks -- again, this will help the TA check that your code (especially for bouncing) is working properly.

Note that the Block class has overridden setX and setY methods -- they add Constants.BLOCK_BORDER to the x and y component respectively.

 

Extra Credit

This assignment is rife with opportunity for extra credit. Here are some things you can implement and the amount of extra credit they will bring.

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

Answers

(5)
Status NEW Posted 13 Dec 2017 12:12 PM My Price 8.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)