The Inbox: MorphicExtras-ct.275.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Inbox: MorphicExtras-ct.275.mcz

commits-2
A new version of MorphicExtras was added to project The Inbox:
http://source.squeak.org/inbox/MorphicExtras-ct.275.mcz

==================== Summary ====================

Name: MorphicExtras-ct.275
Author: ct
Time: 1 October 2019, 11:41:12.160339 pm
UUID: 69cf49c3-5a24-dc40-82a5-df817f82984a
Ancestors: MorphicExtras-ct.267

Adds TetrisPieceMorph example that illustrates usage of PolygonMorphs and random

This commit is part of reconstruction of Objectland (also known as "The Worlds of Squeak"). For more information, see: http://forum.world.st/The-Inbox-MorphicExtras-ct-267-mcz-td5104764.html

=============== Diff against MorphicExtras-ct.267 ===============

Item was added:
+ PolygonMorph subclass: #TetrisPieceMorph
+ instanceVariableNames: ''
+ classVariableNames: 'Colors Shapes Vertices'
+ poolDictionaries: ''
+ category: 'MorphicExtras-Demo'!
+
+ !TetrisPieceMorph commentStamp: 'ct 10/1/2019 23:34' prior: 0!
+ I display a Tetris piece. By calling TetrisPieceMorph random, you can generate a new instance of me that is random in terms of shape, color, and rotation.
+
+ My shapes are: #(i j l o s t z).!

Item was added:
+ ----- Method: TetrisPieceMorph class>>initialize (in category 'class initialization') -----
+ initialize
+
+ super initialize.
+ Vertices := Dictionary new
+ at: #i put: { 0 @ 0. 0 @ 4. 1 @ 4. 1 @ 0 };
+ at: #j put: { 1 @ 0. 1 @ 2. 0 @ 2. 0 @ 3. 2 @ 3. 2 @ 0 };
+ at: #o put: { 0 @ 0. 0 @ 2. 2 @ 2. 2 @ 0 };
+ at: #s put: { 0 @ 0. 0 @ 2. 1 @ 2. 1 @ 3. 2 @ 3. 2 @ 1. 1 @ 1. 1 @ 0 };
+ at: #t put: { 1 @ 0. 1 @ 1. 0 @ 1. 0 @ 2. 3 @ 2. 3 @ 1. 2 @ 1. 2 @ 0 };
+ yourself.
+ Vertices
+ at: #l put: ((Vertices at: #j) * (-1 @ 1));
+ at: #z put: ((Vertices at: #s) * (-1 @ 1)).
+ Shapes := Vertices keys.
+ Colors := #(red green blue orange grape yellow)
+ collect: [:color | color -> (Color in: color) lighter paler]
+ as: Dictionary.!

Item was added:
+ ----- Method: TetrisPieceMorph class>>random (in category 'instance creation') -----
+ random
+ "TetrisPieceMorph random openInHand"
+
+ ^ self
+ shape: Shapes atRandom
+ color: Colors atRandom
+ rotationDegrees: Random new next * 360!

Item was added:
+ ----- Method: TetrisPieceMorph class>>shape:color:rotationDegrees: (in category 'instance creation') -----
+ shape: aShapeSymbol color: aColor rotationDegrees: degrees
+
+ ^ self new
+ shape: aShapeSymbol;
+ color: aColor;
+ rotationDegrees: degrees;
+ yourself!

Item was added:
+ ----- Method: TetrisPieceMorph>>initialize (in category 'initialize-release') -----
+ initialize
+
+ super initialize.
+ self borderStyle: (RaisedBorder new width: 3).!

Item was added:
+ ----- Method: TetrisPieceMorph>>shape: (in category 'initialize-release') -----
+ shape: aShapeSymbol
+
+ self setVertices: (Vertices at: aShapeSymbol) * 20 * RealEstateAgent scaleFactor.!

Item was changed:
+ (PackageInfo named: 'MorphicExtras') postscript: 'TetrisPieceMorph initialize.
+ '!
- (PackageInfo named: 'MorphicExtras') postscript: 'TrashCanMorph preserveTrash: Preferences preserveTrash.
- TrashCanMorph slideDismissalsToTrash: Preferences slideDismissalsToTrash.
-
- Preferences removePreference: #preserveTrash.
- Preferences removePreference: #slideDismissalsToTrash.'!