Section 4

We need to complete the work in the cached forms. Modify the class method #initializeCachedForms on the class LaserGameForms as follows to include our two new mask forms.

initializeCachedForms
    "LaserGameForms initializeCachedForms"
    | form |
    CachedForms := Dictionary new.
    form := self arrowFormFromPointsArray: self northArrowPoints.
    CachedForms at: #north put: form.
    form := self arrowFormFromPointsArray: self eastArrowPoints.
    CachedForms at: #east put: form.
    form := self arrowFormFromPointsArray: self southArrowPoints.
    CachedForms at: #south put: form.
    form := self arrowFormFromPointsArray: self westArrowPoints.
    CachedForms at: #west put: form.
    form := self drawCounterClockwiseArrow.
    CachedForms at: #counterClockwise put: form.
    form := self drawClockwiseArrow.
    CachedForms at: #clockwise put: form.
    form := self drawCrossHair.
    CachedForms at: #crossHair put: form.
    form := self drawLaserBeamForm.
    CachedForms at: #laserBeam put: form.
    form := self drawCenterLaserBeamMask.
    CachedForms at: #centerBeamMask put: form.
    form := self drawSplatterLaserBeamMask.
    CachedForms at: #splatterBeamMask put: form.

Now add the two new class methods to answer the cached masks.

centerBeamMask
    CachedForms isNil ifTrue: [self initializeCachedForms].
    ^CachedForms at: #centerBeamMask

splatterBeamMask
    CachedForms isNil ifTrue: [self initializeCachedForms].
    ^CachedForms at: #splatterBeamMask

When we drew the laser beam from our workspace we applied very specific colors to the components. For the center beam we even chose a new one. We should capture those colors in new class methods on the LaserGameColors class.

laserBeamCenterColor
    ^Color r: 0.909 g: 1.0 b: 0.27

laserBeamSplatterColor
    ^Color r: 1.0 g: 1.0 b: 0.71

Index Page Next Page

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