Section 4

Now all the vertical drawing methods.

renderLaserVerticalMask: aMaskForm color: aColor
    | cellPosn scaledBeam scale trimmedBeam offset rotatedBeam |
    cellPosn := self offsetWithinGridForm.
    scale := CellRenderer cellExtent * 6.
    scaledBeam := aMaskForm scaledToSize: scale.
    trimmedBeam := Form extent: (CellRenderer cellExtent x)@(scaledBeam height) depth: scaledBeam depth.
        displayOn: trimmedBeam
        at: 0@0
        clippingBox: trimmedBeam boundingBox
        rule: Form paint
        fillColor: nil.
    rotatedBeam := trimmedBeam rotateBy: 90.
    offset := (0 + (CellRenderer cellExtent x - rotatedBeam width) // 2)@(3 + (CellRenderer cellExtent y // 2) negated).
        displayOn: self targetForm
        at: (cellPosn + offset)
        clippingBox: self targetForm boundingBox
        rule: Form oldPaint
        fillColor: aColor

        renderLaserVerticalMask: LaserGameForms splatterBeamMask
        color: LaserGameColors laserBeamSplatterColor

        renderLaserVerticalMask: LaserGameForms centerBeamMask
        color: LaserGameColors laserBeamCenterColor

    self renderLaserVerticalSplatter.
    self renderLaserVerticalCenter.

The last piece is to add the instance method that decides which laser path to use.

    | rotate |
    self cell isOff ifTrue: [^self].
    rotate := self cell activeSegments at: #south.
        ifTrue: [self renderLaserVertical]
        ifFalse: [self renderLaserHorizontal].

Index Page Next Page

Copyright © 2007, 2008, 2009, 2010 Stephan B Wessels