Section 4

Since we are visually inspecting the results of drawing our laser beam on the target cell we should really find a way to check for the potential future condition where the laser beam enters the target cell from the north or east side. Moving mirrors around will never accomplish this. The easiest way to do this is use some code that exists on the Grid class to swap the target cell location with another cell.

Command-Click on your LaserGame morph and from the halos select the inspect action from the debug halo. In that open inspector window type the code to swap the location of the two cells we choose.

Now you need to cause the game to redraw the cells that were secretly swapped. The easy way to do that is momentarily hover the cursor over both cells. You should see them correctly repaint in their new swapped locations. You can now close the inspector window.

Now fire up the laser and move mirrors around to ensure that the other 2 sides of the target cell handle the laser beam drawing correctly.

Index Page Next Page

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