Newbie Questions
Lic. Edgar J. De Cleene
edgardec2001 at yahoo.com.ar
Fri Jul 4 14:12:03 UTC 2003
Jeff:
Tailing added, from here you could complete the game.
Edgar
-------------- next part --------------
Morph subclass: #SnakeMorph
instanceVariableNames: 'tail '
classVariableNames: ''
poolDictionaries: ''
category: 'SnakeGame'!
!SnakeMorph methodsFor: 'stepping and presenter' stamp: 'edc 7/4/2003 10:18'!
step
self move! !
!SnakeMorph methodsFor: 'stepping and presenter' stamp: 'edc 7/4/2003 10:12'!
stepTime
"response changes are each second"
^ 1000! !
!SnakeMorph methodsFor: 'creation' stamp: 'edc 7/4/2003 10:10'!
initialize
super initialize.
self openInWorld! !
!SnakeMorph methodsFor: 'creation' stamp: 'edc 7/4/2003 11:04'!
move
| delta p |
delta _ 10 @ 0.
(ActiveWorld bounds containsRect: self bounds)
ifTrue: [p _ self referencePosition + delta.
self referencePosition: p].
self iHaveTail! !
!SnakeMorph methodsFor: 'miscellaneous' stamp: 'edc 7/4/2003 11:03'!
iHaveTail
tail
ifNil: [tail _ TailOfSnakeMorph new]
ifNotNil: [tail width: self left - 5].
! !
Morph subclass: #TailOfSnakeMorph
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'SnakeGame'!
!TailOfSnakeMorph methodsFor: 'creation' stamp: 'edc 7/4/2003 10:49'!
initialize
super initialize.
self color: Color yellow.
self openInWorld! !
More information about the Squeak-dev
mailing list
|