COMP 1671 , Section 1, Fall 2008
Assignment 1
Due September 18, 2008
You are to write a simple simulation in Greenfoot.
There are to be two types a sprites, lets call
them "A-sprites" and "B-sprites". When your simulation starts
there are 10 or more A-sprites on the screen
and one B-sprite.
The A-sprites are to move about the world randomly, reflecting
off of the boundaries. The B-sprite is to be keyboard controlled.
When a B-sprite touches an A-sprite the A-sprite is removed.
You shoudl be able to capture all the B-sprites.
You can use the built in greenfoot actor images if you want, no
need to create your own for this assignment.
Hints/suggestions:
- For the A-sprites Use and x-velocity and
y-velocity data members and negate them when an x or y boundary
is hit.
- First just create then world with the a couple of
A-sprites moving around and one stationary B-sprite.
Second, make sure the A-sprites bounce off the world boundaries
correctly.
Third, make the B-sprite be keyboard controlled.
Last, detect collisions and remove A-sprites.
- Use the "getOneIntersectingObect() method
presented in chapter 3 to detect if the an A-sprite is intersecting
a B-sprite. Put this code in the B-sprite act method.
If there is an intersection call getWorld().removeOBject()
as shown in chapter 3.