Section 2

LaserGame Morph

Create the LaserGame class as a subclass of Morph as shown below.

The LaserGame morph will hold the grid so we create an instance variable for it. Go ahead and create accessors too. Note that we created this class in the graphics system category for our project.

Write the method to calculate the required form size as a class method on our new morph.

Use the new form extent calculation method in our workspace and try it.

You may be asking why not just put this calculation method on the grid object? That makes sense. However, I've tried to avoid putting GUI related code onto the model. So it's on the LaserGame morph for now. We may go back and change that if it becomes more clear it really belongs there after all.

Index Page Next Page

Copyright © 2007, 2008, 2009, 2010 Stephan B Wessels    stevewessels@me.com