Arrow Keys to control movement of a Morph
milan.zimmermann at sympatico.ca
Wed Jul 7 03:05:07 UTC 2004
Thanks for the tip .. did not occur to me to look at games, I was trapped it
the "search Google" and "search Squeak Wiki" approach ... Playing with an
eToy approach to this as well using a patch from Karl,
On July 5, 2004 02:58 am, Alexander Lazarević wrote:
> Hi Milan,
> Look at an existing game by loading it with the PackageLoader from
> SqeakMap. Sokoban for example uses the arrow keys to move a morph
> around. There you will find this methods, which should you get started:
> *handlesKeyboard: aMorphicEvent
> ^ true
> *keyStroke: aKeyboardEvent
> | char |
> char := aKeyboardEvent keyCharacter.
> char = Character arrowLeft ifTrue: [^ self moveLeft].
> char = Character arrowRight ifTrue: [^ self moveRight].
> char = Character arrowUp ifTrue: [^ self moveUp].
> char = Character arrowDown ifTrue: [^ self moveDown].
> char asLowercase = $a ifTrue: [^ self again].
> * [...]
More information about the Squeak-dev