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'
uses #shrinkWrap on the two Example - aRectangleMorph addMorph: anotherMorph:
- an AlingmentMorph with the controls and
- an instance of class SameGameBoard which is subclass of AlignmentMorph
"initialize the state of the receiver"
self listDirection: #topToBottom;
addMorph: self makeControls;
addMorph: self board.
helpText _ nil.
Uses AlignmentMorph newRow, SimpleSwitchMorph and SimpleButtonMorph.
To get larger tiles change the initialize method of SameGameTile to for example
bounds := 0@0 corner: 32@32.