Section 5

I've settled on a workspace window for opening game morphs. It uses the size of 8 x 10 cells. Here's the contents of the Workspace I use to open my LaserGame morphs.

(LaserGame randomizedGridOfExtent: 8@10)
    position: 15@320;
    openInWorld

Open up a LaserGame to see our new panel.

Let's make those counter do something. Add the following methods.

findMirrorsCounter
     ^self allMorphs detect: [:m | m knownName = 'mirrors'] ifNone: []

findActiveMirrorsCounter
     ^self allMorphs detect: [:m | m knownName = 'activeMirrors'] ifNone: []

All we have left do to is modify the #updateCounters method.

updateCounters
     | led |
     led := self findLaserPathCounter.
     led notNil ifTrue: [
         self laserActive
             ifTrue: [led
                 highlighted: true;
                 value: self grid laserBeamPath size]
             ifFalse: [led
                 highlighted: false;
                 value: 0]
             ].
     led := self findMovesCounter.
     led notNil ifTrue: [
         led
            highlighted: false;
            value: self moves asString].
     led := self findMirrorsCounter.
     led notNil ifTrue: [
         led
            highlighted: false;
            value: self grid numberOfMirrors asString].
     led := self findActiveMirrorsCounter.
     led notNil ifTrue: [
         led
            highlighted: false;
            value: self grid numberOfActiveMirrors asString].

Open up a new LaserGame morph and you'll see the new counters in action.

Remember our previous lesson. Run all the unit tests. Then save this package as version 12.

Index Page Next Page

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