Section 4

Since we have "factored" the drawing of our laser beam there's nothing that says we have to keep the colors that were chosen. For fun you could change the color of the center beam. Change the last section of the Workspace to look like this and re-execute.

color := beamForm colorAt: 10@80.
splatterMask
    displayOn: Display
    at: 10@560
    clippingBox: Display boundingBox
    rule: Form oldPaint
    fillColor: color.
centerMask
    displayOn: Display
    at: 10@560
    clippingBox: Display boundingBox
    rule: Form oldPaint
    fillColor: (Color r: 0.909 g: 1.0 b: 0.27)

Another issue we're going to have to deal with before we use these new laser beam masks has to do with symmetry. We free-handed the drawing of our laser beam. And although we made an effort to make most of the drawing uniform, you can clearly see that if we draw these end-to-end it will look funny. Let's fix that now. Continue in your workspace but let's make some changes to make the form twice as wide and we will mirror around the form's center.

LaserGameForms initializeCachedForms.
beamForm := LaserGameForms laserBeam.
newExtent := beamForm extent * (2@1).
splatterForm := Form extent: newExtent depth: beamForm depth.
centerForm := Form extent: newExtent depth: beamForm depth.
beamForm displayOn: splatterForm at: 0@0.
beamForm displayOn: centerForm at: 0@0.
(beamForm flipBy: #horizontal centerAt: 0@0)
    displayOn: splatterForm at: (beamForm width@0);
    displayOn: centerForm at: (beamForm width@0).
color := splatterForm colorAt: 10@60.
splatterForm replaceColor: color withColor: Color white.
centerForm replaceColor: color withColor: Color white.
splatterMask := (splatterForm makeBWForm: Color white) reverse.
color := beamForm colorAt: 10@90.
centerForm replaceColor: color withColor: Color black.
centerMask := centerForm makeBWForm: Color black.
splatterForm displayAt: 10@0.
splatterMask displayAt: 10@200.
centerMask displayAt: 10@400.
color := beamForm colorAt: 10@80.
splatterMask
    displayOn: Display
    at: 10@560
    clippingBox: Display boundingBox
    rule: Form oldPaint
    fillColor: color.
centerMask
    displayOn: Display
    at: 10@560
    clippingBox: Display boundingBox
    rule: Form oldPaint
    fillColor: (Color r: 0.909 g: 1.0 b: 0.27)

Here's the results when we execute.

Index Page Next Page

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