RHS   Allan   Game Techniques Exercises Assignment01


 

Assignment 01

Here is a version of the WormChase game that are stripped for all gathering of statistics (including score and everything). The worm can't use wrap-around: Obstacles.java, Worm.java, WormChase.java and WormPanel.java.

Now you're going to add a class, Mines, that is a dangerous kind of obstacle.
If the worm hits a mine the game is over as it explodes!

Here's the class-diagram that basicly shows that Mines is known by WormPanel :

   

Class Mines
It would be nice to extend the Obstacles class as a mine is-a special kind of obstacle (it explodes!).
Unfortunately the Obstacles class is very porly designed for inheritance (variables are private, but as there is no get-methods the sub-classes will inherit variables they can't access). Let that be a lesson!

So - the easiest way is actually to copy the Obstacles.java into Mines.java and then do minor corrections.

But having a mine class is just first step. Below is recommandations for what you should do to make the mines a part of the game.


Maintained by: Allan Helboe Nielsen
Updated: 3 November, 2005 1:04