Section 4

We also need to change the #boardRelativePositionFor to account for how we moved the control panel and the new margins.

boardRelativePositionFor: evt
    | evtPosn |
    evtPosn := evt hand position.
    ^evtPosn - self position - ((self gameMargin + self panelWidth) @ self gameMargin)

Now we're going to modify colors. Let's start with the easy one. I want the cells to be drawn with a white border. Modify the #cellBorderColor class method on the LaserGameColors class as follows.

    ^Color white

Now we go back to the LaserGame class and modify how the game looks. Add these new instance methods.

    ^ {0.0 -> (Color r: 0.3 g: 0.8 b: 0.9).
        1.0 -> (Color r: 0.2 g: 0.1 b: 0.7)}

    self color: (Color
        r: 0.369
        g: 0.369
        b: 0.505).
    self fillWithRamp: self windowColorRamp oriented: 0.3@0.8

Now we modify the #setupMorphs instance method on the LaserGame class to use these new color setup methods.

    self layoutPolicy: ProportionalLayout new.
    self setWindowColors.
        addMorph: self makeControlPanelMorph
        fullFrame: (LayoutFrame
                fractions: (0 @ 0 corner: 0 @ 1)
                offsets: (self gameMargin @ self gameMargin
                    corner: (self gameMargin + self panelWidth) @ self gameMargin negated)).
        addMorph: self makeGameBoardMorph
        fullFrame: (LayoutFrame
                fractions: (0 @ 0 corner: 1 @ 1)
                offsets: ((self gameMargin + self panelWidth) @ self gameMargin
                    corner: self gameMargin negated @ self gameMargin negated)).

One last step for changes to the colors of the game morph. Modify the #makeControlPanelMorph method so that it is no longer white.

    | panel |
    panel := RectangleMorph new borderWidth: 0;
                 color: Color transparent;
                 layoutPolicy: ProportionalLayout new.
    self addButtonsToPanel: panel.

Okay. Open up a new LaserGame morph and let's have a look.

We're not done. Close the morph before continuing.

Index Page Next Page

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