[ANN] eToy - Wonderland support available

Bertrand Grieu bertrand.grieu at laposte.net
Mon Jun 7 09:57:44 UTC 2004


Hello.

Here is a cs file to provide eToy support for Wonderland.

* make sure you have the Balloon3D package (assuming you have Squeak :) )
* open a file list and make a 'file-in' on this file
* execute 'Vocabulary initialize'
* that's all folks ;)

This has only been tested on a 3.7 version. If you have bugs, 
suggestions, please send them to bertrand.grieu AT laposte DOT net.
-------------- next part --------------
'From Squeak3.7beta of ''1 April 2004'' [latest update: #5868] on 7 June 2004 at 11:28:21 am'!
SymbolListType subclass: #DirectionType
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Protocols-Type Vocabularies'!

!DirectionType commentStamp: 'km 6/7/2004 11:17' prior: 0!
"This class has been created to provide eToys Wonderland support. It has 6 choices : up, down, left, right, forward, back. It is initialized by making 'do it' on the following method :"

"	Vocabulary initialize	"!


!DirectionType methodsFor: 'initialization' stamp: 'km 5/12/2004 16:06'!
initialize
	"Initialize the receiver (automatically called when instances are created via 'new')"

	super initialize.
	self vocabularyName: #Direction.
	symbols _ #(up down right left forward back)! !

!DirectionType methodsFor: 'color' stamp: 'km 5/12/2004 16:05'!
typeColor
	"Answer the color for tiles to be associated with objects of this type"

	^ self subduedColorFromTriplet: #(0.806 1.0 0.806)	! !


!EToyVocabulary methodsFor: 'method list' stamp: 'km 6/7/2004 11:05'!
masterOrderingOfPhraseSymbols
	"Answer a dictatorially-imposed presentation list of phrase-symbols.  This governs the order in which suitable phrases are presented in etoy viewers using the etoy vocabulary.  For any given category, the default implementation is that any items that are in this list will occur first, in the order specified here; after that, all other items will come, in alphabetic order by formal selector."

	^ #(beep: forward: forwardBy: move: turn: roll: getX getY getZ getRotationX getRotationY getRotationZ getHeading getScaleFactor

		getLeft getRight getTop getBottom  
		getLength getWidth 
		getTheta getDistance getHeadingTheta

		startScript: pauseScript: stopScript: startAll: pauseAll: stopAll: tellAllSiblings: doScript:

		getColor getUseGradientFill getSecondColor  getRadialGradientFill  getBorderWidth getBorderColor getBorderStyle getRoundedCorners getDropShadow getShadowColor 

		getGraphic getBaseGraphic)! !


!Vocabulary class methodsFor: 'type vocabularies' stamp: 'km 6/7/2004 11:26'!
newWonderlandVocabulary
	"Answer a Wonderland vocabulary -- still highly experimental. This method is to be executed everytime it is modified."

	| aVocabulary  |
	"Vocabulary newWonderlandVocabulary"
	self removeStandardVocabularyNamed: #Wonderland.
	aVocabulary _ Vocabulary new vocabularyName: #Wonderland.
	aVocabulary documentation: 'A simple vocabulary for scripting Alice objects'.
	aVocabulary initializeFromTable:  #(
	
		(resize:duration: unused (factor Number duration Number) none (basic geometry) 'resizes the actor by `factor` in `duration` seconds') "<--work in progress"
		
		"--"
		(getX setX: () Number (basic geometry) 'The x position' unused updating)
		(getY setY: () Number (basic geometry) 'The y position' unused updating)
		(getZ setZ: () Number (basic geometry) 'The z position' unused updating)
		"--"
		(getRotationX setRotationX: () Number (basic geometry) 'The x rotation' 'x rotation' updating)
		(getRotationY setRotationY: () Number (basic geometry) 'The y rotation' 'y rotation' updating)
		(getRotationZ setRotationZ: () Number (basic geometry) 'The z rotation' 'z rotation' updating)
		"--"
		(width setWidth: () Number (geometry) 'The width of the object' 'width' updating)
		(height setHeight: () Number (geometry) 'The height of the object' 'height' updating)
		(depth setDepth: () Number (geometry) 'The depth of the object' 'depth' updating)
		"--"
		(heading setHeading: () Number (geometry) 'The heading of the object' 'heading' updating)
		(forwardBy: unused ((distance Number)) none (motion) 'Moves the object by the specified distance' 'forward by')
		(move: unused ((direction Direction)) none (basic motion) 'Moves the object in the specified direction' 'move')
		(turn: unused ((direction Direction)) none (basic motion) 'Turns the actor in the specified direction' 'turn')
		(roll: unused ((direction Direction)) none (basic motion) 'Rolls the actor in the specified direction' 'roll')
		"--"
		(moveUpDistance: unused ((distance Number)) none (motion) 'Moves the object up by the specified distance' unused)
		(moveDownDistance: unused ((distance Number)) none (motion) 'Moves the object down by the specified distance' unused)
		(moveForwardDistance: unused ((distance Number)) none (motion) 'Moves the object forward by the specified distance' unused)
		(moveBackDistance: unused ((distance Number)) none (motion) 'Moves the object back by the specified distance' unused)
		(moveRightDistance: unused ((distance Number)) none (motion) 'Moves the object right by the specified distance' unused)
		(moveLeftDistance: unused ((distance Number)) none (motion) 'Moves the object left by the specified distance' unused)
		(turnUpAngle: unused ((angle Number)) none (motion) 'Turns the object up by the specified angle' unused)
		(turnDownAngle: unused ((angle Number)) none (motion) 'Turns the object down by the specified angle' unused)
		(turnForwardAngle: unused ((angle Number)) none (motion) 'Turns the object forward by the specified angle' unused)
		(turnBackAngle: unused ((angle Number)) none (motion) 'Turns the object back by the specified angle' unused)
		(turnRightAngle: unused ((angle Number)) none (motion) 'Turns the object right by the specified angle' unused)
		(turnLeftAngle: unused ((angle Number)) none (motion) 'Rolls the object up by the specified angle' unused)
		(rollDownAngle: unused ((angle Number)) none (motion) 'Rolls the object down by the specified angle' unused)
		(rollForwardAngle: unused ((angle Number)) none (motion) 'Rolls the object forward by the specified angle' unused)
		(rollBackAngle: unused ((angle Number)) none (motion) 'Rolls the object back by the specified angle' unused)
		(rollRightAngle: unused ((angle Number)) none (motion) 'Rolls the object right by the specified angle' unused)
		(rollLeftAngle: unused ((angle Number)) none (motion) 'Rolls the object left by the specified angle' unused)		
				"--"
		"(turnBy: unused ((angle Number)) none (motion) 'Turns the object by the specified number of degrees' 'pouet ')" "<-- made obsolete by turn[Direction]Angle: methods"
		(resize: unused ((factor Number)) none (geometry) 'Resizes the actor by the specified factor' 'resize by')
		(graphic setGraphic: () Graphic (graphics) 'The picture currently being worn' unused updating)
		(animationIndex setAnimationIndex: () Number (graphics) 'The index in the object''s animation chain' unused updating)
		"(emptyScript unused () none (scripts) 'The empty script')" "<-- so buggy and not so useful so I suppressed it"
		(distanceToCamera setDistanceToCamera: () Number (geometry) 'The distance of the object from the camera' unused updating)
		(distanceTo: unused ((target Player)) Number (geometry) 'The distance of the object to the given target')
	).
	^ aVocabulary! !


!WonderlandActor methodsFor: 'primitive behaviors' stamp: 'km 5/17/2004 14:34'!
moveBackDistance: aDistance 
	"Move the actor the specified distance in the back direction, taking 1 second and using the Gently animation style."

	^ (self move: #back distance: aDistance duration: 1.0
			style: gently).

! !

!WonderlandActor methodsFor: 'primitive behaviors' stamp: 'km 5/17/2004 14:33'!
moveDownDistance: aDistance 
	"Move the actor the specified distance in the down direction, taking 1 second and using the Gently animation style."

	^ (self move: #down distance: aDistance duration: 1.0
			style: gently).

! !

!WonderlandActor methodsFor: 'primitive behaviors' stamp: 'km 5/17/2004 14:34'!
moveForwardDistance: aDistance 
	"Move the actor the specified distance in the forward direction, taking 1 second and using the Gently animation style."

	^ (self move: #forward distance: aDistance duration: 1.0
			style: gently).

! !

!WonderlandActor methodsFor: 'primitive behaviors' stamp: 'km 5/17/2004 14:33'!
moveLeftDistance: aDistance 
	"Move the actor the specified distance in the left direction, taking 1 second and using the Gently animation style."

	^ (self move: #left distance: aDistance duration: 1.0
			style: gently).

! !

!WonderlandActor methodsFor: 'primitive behaviors' stamp: 'km 5/17/2004 14:33'!
moveRightDistance: aDistance 
	"Move the actor the specified distance in the right direction, taking 1 second and using the Gently animation style."

	^ (self move: #right distance: aDistance duration: 1.0
			style: gently).

! !

!WonderlandActor methodsFor: 'primitive behaviors' stamp: 'km 5/17/2004 14:33'!
moveUpDistance: aDistance 
	"Move the actor the specified distance in the up direction, taking 1 second and using the Gently animation style."

	^ (self move: #up distance: aDistance duration: 1.0
			style: gently).

! !

!WonderlandActor methodsFor: 'primitive behaviors' stamp: 'km 6/7/2004 10:57'!
rollBackAngle: angle 
	"Roll the actor the specified angle in the back direction,  
	taking 1 second and using the Gently animation style."
	^ self
		roll: #back
		turns: angle / 360
		duration: 1.0
		style: gently! !

!WonderlandActor methodsFor: 'primitive behaviors' stamp: 'km 6/7/2004 10:59'!
rollDownAngle: angle 
	"Roll the actor the specified angle in the down direction,  
	taking 1 second and using the Gently animation style."
	^ self
		roll: #down
		turns: angle / 360
		duration: 1.0
		style: gently! !

!WonderlandActor methodsFor: 'primitive behaviors' stamp: 'km 6/7/2004 10:57'!
rollForwardAngle: angle 
	"Roll the actor the specified angle in the forward direction,  
	taking 1 second and using the Gently animation style."
	^ self
		roll: #forward
		turns: angle / 360
		duration: 1.0
		style: gently! !

!WonderlandActor methodsFor: 'primitive behaviors' stamp: 'km 6/7/2004 10:58'!
rollLeftAngle: angle 
	"Roll the actor the specified angle in the left direction,  
	taking 1 second and using the Gently animation style."
	^ self
		roll: #left
		turns: angle / 360
		duration: 1.0
		style: gently! !

!WonderlandActor methodsFor: 'primitive behaviors' stamp: 'km 6/7/2004 10:58'!
rollRightAngle: angle 
	"Roll the actor the specified angle in the right direction,  
	taking 1 second and using the Gently animation style."
	^ self
		roll: #right
		turns: angle / 360
		duration: 1.0
		style: gently! !

!WonderlandActor methodsFor: 'primitive behaviors' stamp: 'km 6/7/2004 10:58'!
rollUpAngle: angle 
	"Roll the actor the specified angle in the up direction,  
	taking 1 second and using the Gently animation style."
	^ self
		roll: #up
		turns: angle / 360
		duration: 1.0
		style: gently! !

!WonderlandActor methodsFor: 'primitive behaviors' stamp: 'km 5/25/2004 10:28'!
turnBackAngle: anAngle 
	"Turn the actor the specified angle in the back direction, taking 1  
	second and using the Gently animation style."
	^ self
		turn: #back
		turns: anAngle / 360
		duration: 1.0
		style: gently! !

!WonderlandActor methodsFor: 'primitive behaviors' stamp: 'km 5/25/2004 10:27'!
turnDownAngle: anAngle 
	"Turn the actor the specified angle in the down direction, taking 1  
	second and using the Gently animation style."
	^ self
		turn: #down
		turns: anAngle / 360
		duration: 1.0
		style: gently! !

!WonderlandActor methodsFor: 'primitive behaviors' stamp: 'km 5/25/2004 10:27'!
turnForwardAngle: anAngle 
	"Turn the actor the specified angle in the forward direction, taking 1  
	second and using the Gently animation style."
	^ self
		turn: #forward
		turns: anAngle / 360
		duration: 1.0
		style: gently! !

!WonderlandActor methodsFor: 'primitive behaviors' stamp: 'km 5/25/2004 10:26'!
turnLeftAngle: anAngle 
	"Turn the actor the specified angle in the left direction, taking 1  
	second and using the Gently animation style."
	^ self
		turn: #left
		turns: anAngle/360
		duration: 1.0
		style: gently! !

!WonderlandActor methodsFor: 'primitive behaviors' stamp: 'km 5/25/2004 10:26'!
turnRightAngle: anAngle 
	"Turn the actor the specified angle in the lefrightt direction, taking 1  
	second and using the Gently animation style."
	^ self
		turn: #right
		turns: anAngle/360
		duration: 1.0
		style: gently! !

!WonderlandActor methodsFor: 'primitive behaviors' stamp: 'km 5/25/2004 10:26'!
turnUpAngle: anAngle 
	"Turn the actor the specified angle in the up direction, taking 1  
	second and using the Gently animation style."
	^ self
		turn: #up
		turns: anAngle / 360
		duration: 1.0
		style: gently! !

!WonderlandActor methodsFor: 'eToy-basic' stamp: 'km 5/18/2004 14:11'!
getRotationX
	^ (self getPointOfView at: 4)! !

!WonderlandActor methodsFor: 'eToy-basic' stamp: 'km 5/18/2004 14:11'!
getRotationY
	^ self getPointOfView at: 5! !

!WonderlandActor methodsFor: 'eToy-basic' stamp: 'km 5/18/2004 14:11'!
getRotationZ
	^ self getPointOfView at: 6! !

!WonderlandActor methodsFor: 'eToy-basic' stamp: 'km 5/18/2004 14:10'!
setRotationX: value 
	"Sets the object's x orientation"
	^ self setPointOfView: (self getPointOfView at: 4 put: value;
			 yourself) duration: rightNow! !

!WonderlandActor methodsFor: 'eToy-basic' stamp: 'km 5/18/2004 14:10'!
setRotationY: value 
	"Sets the object's y orientation"
	^ self setPointOfView: (self getPointOfView at: 5 put: value;
			 yourself) duration: rightNow! !

!WonderlandActor methodsFor: 'eToy-basic' stamp: 'km 5/18/2004 14:10'!
setRotationZ: value 
	"Sets the object's z orientation"
	^ self setPointOfView: (self getPointOfView at: 6 put: value;
			 yourself) duration: rightNow! !

!WonderlandActor methodsFor: 'eToy-basic' stamp: 'km 5/5/2004 11:10'!
turnLeftBy: angle 
	"Note: This uses turns as in Alice"
	self
		turn: #left
		turns: angle
		duration: rightNow
		asSeenBy: self! !

!WonderlandActor methodsFor: 'eToy-support' stamp: 'km 5/18/2004 14:20'!
decimalPlacesForGetter: aGetter
^nil! !

WonderlandActor removeSelector: #rollBackTurns:!
WonderlandActor removeSelector: #rollDownTurns:!
WonderlandActor removeSelector: #rollForwardTurns:!
WonderlandActor removeSelector: #rollLeftTurns:!
WonderlandActor removeSelector: #rollRightTurns:!
WonderlandActor removeSelector: #rollUpTurns:!
WonderlandActor removeSelector: #turnLRightAngle:!
WonderlandActor removeSelector: #turnLRighttAngle:!


More information about the Squeak-dev mailing list