Fugu Chase *
In this scenario, a shark is chasing a small fish: The fish darts
about randomly, while the shark methodically moves toward it. If the
shark ever comes close to making contact with the fish, then the fish expands to
many times its original size and the shark swims away in fear.
This is a fairly complicated animation. I suggest that you complete
it by breaking the problem into several pieces, each of which should
be solved and tested in turn:
Step #1: Random Fish
In order to create the effect of a randomly moving fish, you can use
an If/Else statment inside a loop. The If/Else can be conditioned on
the world level function choose true 50% of the time which
randomly returns either true or false. If the result is true, then
the fish moves foward and to the left, if the result is false, then
the fish moves forward and to the right. HINT: Motions inside of a
loop will look jerky as they start and stop each time through the
loop. This can be addressed by making sure that the style of the
motions is set to be "abruptly".
Step #2: Terrifying Shark
Every time the fish moves, the shark should simultaneously move toward
him. This will look most realistic if the shark turns to face the
fish and moves forward at the same time. In order to make for
an exciting chase the shark should move some smallish fixed interval
on every time step.
Step #3: The Exciting Conclusion
At this point, you should have a realistic looking chase, with an
anticlimactic conclusion - nothing happens when the shark catches the
fish. Your last step is to modify the code so that it checks to see
if the shark has gotten sufficiently close to the fish, and generates
the appropriate animation when it has. Your check for "sufficiently
close" should take into account the sizes of the two animals. In other
words, the animation should still look right if the fish and shark are
re-sized.
Remember that the distance between two objects is measured as the
distance between the centers of the objects. You will not be able to
get the fish to expand exactly when the two objects touch.
Extras **