CSE 131 Module 11: Class Hierarchies

Studio


Studio 11

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).

Warmup


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.


  1. Documentation for the classes can be found here. You may want to keep a window open with the documentation viewable.
  2. 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.
  3. Right-click Main and choose Run As ... Java Application. You will see the game behaving as it did in lecture:
  4. 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 at Bricks.


  5. 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
  6. When ready, follow the FIXME suggestion and comment out the TickMover associated with bricks so that bricks will stay still.
  7. 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.

  8. Let's look at genBall(). Follow the TRYME suggestions you see there to change how the ball behaves:
  9. 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.
  10. 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.
  11. 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)



Last modified 11:06:35 CST 27 November 2009 by Ron K. Cytron