Section 4

Laser On Target Cell

Drawing the laser beam onto the target cell should be a lot like drawing on the blank cells. The difference will be that the beam will travel only half way across the target call and we will want to show the target itself, so the laser has to skip over that part of the cell drawing.

We will follow the same pattern as before. Here are the new instance methods for the TargetCellRenderer class.

The circle/target drawing is re-factored to make it easy to specify the position and output form.

drawCircleOutlineOn: aForm color: aColor offset: offset
    | delta fillForm circle |
    delta := self class cellExtent - 1.
    circle := Circle new.
    fillForm := Form extent: 2@2 depth: 8.
    fillForm fillColor: aColor.
    circle form: fillForm.
    circle radius: self radius.
    circle center: (offset + (delta // 2)).
    circle displayOn: aForm

drawCircleOutlineOn: aForm color: aColor
    | offset |
    offset := self offsetWithinGridForm.
    self drawCircleOutlineOn: aForm color: aColor offset: offset

    self drawCircleOutlineOn: self targetForm color: LaserGameColors targetCenterColor

Index Page Next Page

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