CSE 131 Module 11: Class Hierarchies
This studio continues the work of
Studio 10 and builds toward the completion
of your game.
It would be a good idea to partner with people with whom you
will complete the Lab and
bridge/extension (programming contest entry).
- One of you should log in, launch eclipse, and
open the SVN Repository Exploring perspective:
Window...Open Perspective...Other...SVN Repository Exploring
- Click on the New Repository Location icon (looks like a
gold battery with a green plus sign).
- Copy the following URL using your mouse:
- Change XXXXX to your username that you use to log into cec computers. For example, jdl2.
- Be sure the directory after fall09 is studios and
- Change ZZZZZZ to the word on your sticker.
For example, animal.
- If prompted, type in your name and password.
- If the repository is validated, keep going; otherwise get help.
- Right-click on the project name and Check Out the workspace.
- Return to the Java perspective.
- You will need somebody's lab4 implementation.
Copy and paste a working lab4 package into your studio11 project.
Be sure to paste it into the src component of your workspace,
not at the top level.
You continue your work on BrickBreaker, this time working on objects
that move and collide.
Go as far as you can with this, and feel free to experiment. Show your work to
TAs as you go and interact with other groups if you have ideas to share or need help.
- Documentation for the classes can be found
here. You may want to keep
a window open with the documentation viewable.
- The code is annotated with TRY and FIXME directives, which should show
up in the navigation bar of eclipse when you load this studio.
They appear as blue rectangles, which when clicked will take you to
a specific comment in the code.
- Right-click Main and choose Run As ... Java Application.
You will see the game behaving as it did in lecture:
- At the first TRY comment in the Controller constructor,
add some more genBall() method calls
to create 2, 3, or more Balls. You could write a loop or just copy/paste
the genBall() call as many times as you like.
We'll return to the Ball objects later. We next look
- Open up the Controller class and look at the FIXME in the
genBricks() method. You will see the TickMover
that is attached to each brick. If you like, play with the values
set for the velocity and acceleration
- When ready, follow the FIXME suggestion and comment out the
TickMover associated with bricks so that bricks will stay
- Still in the genBricks method, take a look at the suggestions
above the assignment to Brick b. Write a helper method:
private Brick makeOneBrick(....)
that takes in whatever information you need and returns, for now, a
new Brick(p, bwidth, bheight, panel) as constructed currently.
You will have to pass to makeOneBrick at least the parameters currently used by
the Brick constructor.
When you extend Brick, your helper method can generate one
of your extensions in place of the ordinary Brick.
Ask the TA or other students for help if this is unclear.
- Let's look at genBall(). Follow the TRYME suggestions
you see there to change how the ball behaves:
- Try different velocities. The code now uses (512,512) as the velocity
- Comment out the PaddleCheater so that only you have control
of the Paddle.
- Try attaching a DirectionChanger to the floor, so that
if the ball hits the floor, it bounces.
- Currently, the Controller determines the velocity that the
Ball should have. Suppose we want to make different kinds of Balls, each
able to determine its own starting velocity.
- Add the method Vector getStartingVelocity() to the Ball
class, and use its result to set the velocity in Controller.
- In the future, you can extend Ball and override
getStartingVelocity() to create different kinds of Balls.
- Now let's do something when the ball hits a brick. There is the
beginning of BallHitsBrick in the game.collision package.
Take a look at BallHitsFloor and BallHitsPaddle and
try to model BallHitsBrick after that.
If eclipse can't resolve a name, try clicking on the yellow help bulb
as that will suggest possible locations from which the name can be imported.
At the very least, get your code to print out a message when the ball
hits a brick.
Then you can try to get the brick to die.
- Spend the rest of your time brainstorming about brick variations
and ball variations you want to try for your game. Try to get some of
those implementations underway. Ask if you need or want some help!
Submitting your work (read carefully)
- Complete the feedback.txt file and be sure to list
your group members' names and ID last-3-digits.
- Answer the other questions in the feedback.txt file.
- You must commit all of your work to your repository. It's best to do this
from the top-most level of your repository, which bears your name and student ID.
- You must have the TA clear you by signing your studio group sheet.
Be sure your names and IDs are written
clearly on the TA's demo sheet.
Last modified 11:06:35 CST 27 November 2009
by Ron K. Cytron