BorderedMorph subclass: #DieMorph instanceVariableNames: 'faces dieValue isStopped' classVariableNames: '' poolDictionaries: '' category: 'SBE-Morphic'! !DieMorph commentStamp: 'sa 5/28/2009 14:30' prior: 0! Ez egy dobókockát reprezentáló osztály. ! !DieMorph methodsFor: 'faces' stamp: 'sa 5/28/2009 14:50'! dieValue: aNumber (aNumber isInteger and: [aNumber > 0] and: [aNumber <= faces]) ifTrue: [dieValue := aNumber. self changed]! ! !DieMorph methodsFor: 'faces' stamp: 'sa 5/28/2009 14:35'! face1 ^{0.5@0.5}! ! !DieMorph methodsFor: 'faces' stamp: 'sa 5/28/2009 14:35'! face2 ^{0.25@0.25 . 0.75@0.75}! ! !DieMorph methodsFor: 'faces' stamp: 'sa 5/28/2009 14:35'! face3 ^{0.25@0.25 . 0.75@0.75 . 0.5@0.5}! ! !DieMorph methodsFor: 'faces' stamp: 'sa 5/28/2009 14:35'! face4 ^{0.25@0.25 . 0.75@0.25 . 0.75@0.75 . 0.25@0.75}! ! !DieMorph methodsFor: 'faces' stamp: 'sa 5/28/2009 14:35'! face5 ^{0.25@0.25 . 0.75@0.25 . 0.75@0.75 . 0.25@0.75 . 0.5@0.5}! ! !DieMorph methodsFor: 'faces' stamp: 'sa 5/28/2009 14:36'! face6 ^{0.25@0.25 . 0.75@0.25 . 0.75@0.75 . 0.25@0.75 . 0.25@0.5 . 0.75@0.5}! ! !DieMorph methodsFor: 'faces' stamp: 'sa 5/28/2009 14:36'! face7 ^{0.25@0.25 . 0.75@0.25 . 0.75@0.75 . 0.25@0.75 . 0.25@0.5 . 0.75@0.5 . 0.5@0.5}! ! !DieMorph methodsFor: 'faces' stamp: 'sa 5/28/2009 14:36'! face8 ^{0.25@0.25 . 0.75@0.25 . 0.75@0.75 . 0.25@0.75 . 0.25@0.5 . 0.75@0.5 . 0.5@0.5 . 0.5@0.25}! ! !DieMorph methodsFor: 'faces' stamp: 'sa 5/28/2009 14:36'! face9 ^{0.25@0.25 . 0.75@0.25 . 0.75@0.75 . 0.25@0.75 . 0.25@0.5 . 0.75@0.5 . 0.5@0.5 . 0.5@0.25 . 0.5@0.75}! ! !DieMorph methodsFor: 'initialization' stamp: 'sa 5/28/2009 14:32'! initialize super initialize. self extent: 50 @ 50. self useGradientFill; borderWidth: 2; useRoundedCorners. self setBorderStyle: #complexRaised. self fillStyle direction: self extent. self color: Color green. dieValue := 1. faces := 6. isStopped := false! ! !DieMorph methodsFor: 'drawing' stamp: 'sa 5/28/2009 14:37'! drawDotOn: aCanvas at: aPoint aCanvas fillOval: (Rectangle center: self position + (self extent * aPoint) extent: self extent / 6) color: Color black! ! !DieMorph methodsFor: 'drawing' stamp: 'sa 5/28/2009 14:38'! drawOn: aCanvas super drawOn: aCanvas. (self perform: ('face' , dieValue asString) asSymbol) do: [:aPoint | self drawDotOn: aCanvas at: aPoint]! ! !DieMorph methodsFor: 'event handling' stamp: 'sa 5/28/2009 14:52'! handlesMouseDown: anEvent ^true! ! !DieMorph methodsFor: 'event handling' stamp: 'sa 5/28/2009 14:52'! mouseDown: anEvent anEvent redButtonPressed ifTrue: [isStopped := isStopped not]! ! !DieMorph methodsFor: 'stepping and presenter' stamp: 'sa 5/28/2009 14:51'! step isStopped ifFalse: [self dieValue: (1 to: faces) atRandom]! ! !DieMorph methodsFor: 'testing' stamp: 'sa 5/28/2009 14:51'! stepTime ^100 ! !