Add the following instance methods to the LaserGame class.
makeMirrorsCounterMorph
| count |
count := LedMorph new
digits: 3;
extent: 3 * 10 @ 15;
setBalloonText: ''.
count color: (Color r: 0.674 g: 0.674 b: 0.96).
count name: 'mirrors'.
^ self wrapPanel: count label: 'Mirrors'
makeActiveMirrorsCounterMorph
| count |
count := LedMorph new
digits: 3;
extent: 3 * 10 @ 15;
setBalloonText: ''.
count color: (Color r: 0.674 g: 0.674 b: 0.96).
count name: 'activeMirrors'.
^ self wrapPanel: count label: 'Active Mirrors'
Before proceeding, close any open LaserGame morphs you may have. The next section of code changes some of the active dimensions of the game morph and can get event processing pretty messed up if a game board is open.
The panel for our controls needs to be a little wider because of the larger tag in the active mirrors counter. Modify the #panelWidth method.
panelWidth
^110
Next, modify the #addCountersToPanel: method to add our new counters.
addCountersToPanel: panel
panel
addMorph: self makeLaserPathCounterMorph
fullFrame: (LayoutFrame
fractions: (0 @ 0 corner: 1 @ 0)
offsets: (4 @ 4 corner: -8 @ 44));
addMorph: self makeMovesCounterMorph
fullFrame: (LayoutFrame
fractions: (0 @ 0 corner: 1 @ 0)
offsets: (4 @ 48 corner: -8 @ 92));
addMorph: self makeMirrorsCounterMorph
fullFrame: (LayoutFrame
fractions: (0 @ 0 corner: 1 @ 0)
offsets: (4 @ 96 corner: -8 @ 140));
addMorph: self makeActiveMirrorsCounterMorph
fullFrame: (LayoutFrame
fractions: (0 @ 0 corner: 1 @ 0)
offsets: (4 @ 144 corner: -8 @ 188))