|
Comp201: Principles of Object-Oriented Programming I
Spring 2006 -- Lab 14: The Start of
BallWar
|
In this lab, we will begin our final project, BallWar.
For complete details of the final project, see the
final project assignment page.
Adding Collisions
If you download the code from the assignment page, you will notice that the
collision behavior is not fully implemented. In fact, there is only one thing
that has been removed and that is what we will try to fix now.
First, read the sections in the assignment page on command
dispatching and collisions.
- In the Ball class, you will
see that the _collisionCmd
variable is uninitialized. Initialize that variable using an anonymous inner
class. This command will be used to check if a given ball has collided with
any other balls in the system. Follow the stipulations given in the documentation
very carefully!
- In the updateState method
of Ball, you will see that
there is a blank section where the ball needs to use the environment's dispatcher
to check for collisions. Use your newly initialized _collisionCmd here to
check to see if this ball has collided with any other balls.
- Recompile your work and try running it. Collision detection and any associated
behaviors should now be active!
You are now ready to commence your final project! Go for it!
Last Revised
Thursday, 03-Jun-2010 09:50:13 CDT
©2006 Stephen Wong and Dung Nguyen