Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
SameGame
Last updated at 11:04 am UTC on 12 September 2016
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.

The classes

are needed. The game is then available through the 'objects' Flap in the 'Games' category.

Definition of the game
AlignmentMorph subclass: #SameGame
	instanceVariableNames: 'board scoreDisplay selectionDisplay helpText'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Morphic-Games'



The
 SameGame initialize

uses #shrinkWrap on the two Example - aRectangleMorph addMorph: anotherMorph:


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.


To get larger tiles change the initialize method of SameGameTile to for example

 bounds := 0@0 corner: 32@32.