Introduction:
In this lab you will
build the second
part of a one level graphical game. You will now add a single line of "blocks" to your
Objective:
The high level objectives of this lab are:
- Use a UML
diagram to help you continue writing your program from a given program
design.
- use collections
- use the rectangle class.
What you must do:
Extend your project 6 according to the following UML diagram. (As
usual, you may add additional funcationality so long as you meet this
minimum specification)
For those who have not been able to complete Lab6. A sample solution is available. Therefore no late lab6 solutions will be accepted. Submission for lab 6 is now closed.
Your program should look something like this:
Where the ball bounces around. If the ball hits a block, that block should disappear.
Some specifics:
- Block class
- the constructor should setup the color for the block. (you may
include a third parameter if you like, You may also use a single color
for all of the blocks, in which case it will look like one lon line
until one of the blocks disappears). The constructor also needs to take
the x and y passed in and initialize _xPos and _yPos
- paint takes a Graphics objects as its parameter (just like the
paint in the Ball class did.) The job of this method is to paint the
block.
- The WIDTH and HEIGHT attributes are constants representing the
width and height of the blocks. You may change the values from the ones
I've used.
- GamePanel
- We've added one instance variable. You should initialize it in the constructor and fill it with blocks
- You must have at least 5 block objects in your solution.
- The paintComponent method needs to be expanded to loop through the _blockList and call paint on each of the blocks.
- Ball
- the paint method needs to be expanded yet again to check for
intersections between the ball and a block. If there is an
intersection, remove that block from the list. (you will need to
provide some way for the Ball object to get the list from the GamePanel
object. You might add a second parameter to paint, or provide some
other means of sharing the information between the two objects.
Submitting
When you submit this time, add a readme.txt file to your lab6 folder (as with lab5, feel free to reuse your lab6 folder). The
readme should contain:
- Your name.
- A very brief summary of what you did, including any new methods you added and why you chose to implement things the way you did.
- Directions on how to run your program and anything unusual that I need to do to get it working properly.
- A list of any problems still in your code or anything that you didn't get done.
Once your readme is in place, submit as usual with the online
submission. Use your last and and the project number in your zip file
name