SameGame
Last updated at 12:01 am UTC on 26 November 2017
Squeak (version 3.8.1) contains a nice game which may serve as an example of using AlignmentMorphs.
The fileOut of the 'Morphic-Games' category of Squeak 3.8.1 works in Squeak 5.1. In Squeak 6.0a it is included again with other games in the category 'Etoys-Squeakland-Morphic-Games'

The game is available through the 'objects' Flap in the 'Games' category.
Alternatively open it in a Workspace with
SameGame new openInWorld
Notes about the implementation
The game is built with the following classes
- SameGameTile (Subclass of AlignmentMorph)
- SameGameBoard (Subclass of AlignmentMorph)
- SameGame (Subclass of SimpleSwitchMorph)
Definition of the SameGame class
AlignmentMorph subclass: #SameGame
instanceVariableNames: 'board scoreDisplay selectionDisplay helpText'
classVariableNames: ''
poolDictionaries: ''
category: 'Morphic-Games'
The
SameGame initialize
uses #shrinkWrap on the two Example - aMorph addMorph: anotherMorph (no layout and TableLayout):
- an AlingmentMorph with the controls and
- an instance of class SameGameBoard which is subclass of AlignmentMorph
initialize
"initialize the state of the receiver"
super initialize.
""
self listDirection: #topToBottom;
wrapCentering: #center;
cellPositioning: #topCenter;
vResizing: #shrinkWrap;
hResizing: #shrinkWrap;
layoutInset: 3;
addMorph: self makeControls;
addMorph: self board.
helpText _ nil.
self newGame
.
and
SameGame makeControls
Uses AlignmentMorph newRow, SimpleSwitchMorph and SimpleButtonMorph.
SameGameTile
To get larger tiles change the initialize method of SameGameTile to for example
bounds := 0@0 corner: 32@32.