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 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'


SameGame.png
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


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 - 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.


SameGameTile

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

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