BorderedMorph subclass: #JPEnemy instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Itolab-JackPot'! !JPEnemy methodsFor: 'accessing' stamp: 'EiichiroIto 8/1/2011 20:55'! doWithPlayer: aPlayer owner missed! ! !JPEnemy methodsFor: 'accessing' stamp: 'EiichiroIto 8/1/2011 20:55'! isCollidedWith: aPoint ^ (self center dist: aPoint) < 16! ! !JPEnemy methodsFor: 'accessing' stamp: 'EiichiroIto 8/1/2011 20:58'! move | position | position := owner player center. self center: self center - ((self center - position) sign * 2)! ! !JPEnemy methodsFor: 'initialization' stamp: 'EiichiroIto 8/1/2011 20:56'! initialize super initialize. self borderWidth: 1. self extent: 16 @ 16. self color: Color red! ! BorderedMorph subclass: #JackPot instanceVariableNames: 'key player' classVariableNames: '' poolDictionaries: '' category: 'Itolab-JackPot'! !JackPot methodsFor: 'initialization' stamp: 'EiichiroIto 8/1/2011 20:41'! initialize super initialize. self color: Color black. self extent: 640 @ 480. self borderWidth: 0. key := 0. self setup! ! !JackPot methodsFor: 'initialization' stamp: 'EiichiroIto 8/1/2011 20:44'! setup | obj | player := JPPlayer new. player center: self center. self addMorphFront: player. 8 timesRepeat: [ obj := JPTreasure new. obj position: bounds topLeft + (640 atRandom @ 480 atRandom). self addMorphFront: obj ]. obj := JPEnemy new. obj position: bounds topLeft + (50 @ 240). self addMorphFront: obj! ! !JackPot methodsFor: 'private' stamp: 'EiichiroIto 8/1/2011 20:47'! countTreasure ^ self submorphs count: [ :each | each isKindOf: JPTreasure ]! ! !JackPot methodsFor: 'event handling' stamp: 'EiichiroIto 8/1/2011 20:44'! handlesKeyboard: anEvent ^ true! ! !JackPot methodsFor: 'event handling' stamp: 'EiichiroIto 8/1/2011 20:44'! handlesMouseDown: anEvent ^ true! ! !JackPot methodsFor: 'event handling' stamp: 'EiichiroIto 8/6/2011 15:07'! keyDown: anEvent | v | v := anEvent keyValue. v = 28 ifTrue: [key := key bitOr: 1]. v = 29 ifTrue: [key := key bitOr: 2]. v = 31 ifTrue: [key := key bitOr: 4]. v = 30 ifTrue: [key := key bitOr: 8]! ! !JackPot methodsFor: 'event handling' stamp: 'EiichiroIto 8/6/2011 15:07'! keyUp: anEvent | v | v := anEvent keyValue. v = 28 ifTrue: [key := key bitAnd: 1 bitInvert]. v = 29 ifTrue: [key := key bitAnd: 2 bitInvert]. v = 31 ifTrue: [key := key bitAnd: 4 bitInvert]. v = 30 ifTrue: [key := key bitAnd: 8 bitInvert]! ! !JackPot methodsFor: 'event handling' stamp: 'EiichiroIto 8/1/2011 20:45'! mouseDown: anEvent anEvent hand keyboardFocus: self! ! !JackPot methodsFor: 'stepping and presenter' stamp: 'EiichiroIto 8/1/2011 20:47'! step self submorphs do: [ :each | each move ]! ! !JackPot methodsFor: 'stepping and presenter' stamp: 'EiichiroIto 8/1/2011 20:46'! stepTime ^ 100! ! !JackPot methodsFor: 'stepping and presenter' stamp: 'EiichiroIto 8/1/2011 20:46'! wantsSteps ^ true! ! !JackPot methodsFor: 'accessing' stamp: 'EiichiroIto 8/1/2011 20:48'! gotTreasure self countTreasure = 0 ifTrue: [ self inform: 'You win!!'. self delete ]! ! !JackPot methodsFor: 'accessing' stamp: 'EiichiroIto 8/1/2011 20:50'! key ^ key! ! !JackPot methodsFor: 'accessing' stamp: 'EiichiroIto 8/1/2011 20:48'! missed self inform: 'Game Over!!'. self delete! ! !JackPot methodsFor: 'accessing' stamp: 'EiichiroIto 8/1/2011 20:48'! player ^ player! ! BorderedMorph subclass: #JPPlayer instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Itolab-JackPot'! !JPPlayer methodsFor: 'initialization' stamp: 'EiichiroIto 8/1/2011 20:49'! initialize super initialize. self borderWidth: 1. self extent: 16 @ 16. self color: Color blue! ! !JPPlayer methodsFor: 'private' stamp: 'EiichiroIto 8/1/2011 20:49'! checkCollision owner submorphs do: [ :each | (each isCollidedWith: self center) ifTrue: [ each doWithPlayer: self ] ]! ! !JPPlayer methodsFor: 'private' stamp: 'EiichiroIto 8/6/2011 14:18'! processKeys | key position | key := owner key. position := self center. (key anyMask: 1) ifTrue: [ position := -2 @ 0 + position ]. (key anyMask: 2) ifTrue: [ position := 2 @ 0 + position ]. (key anyMask: 4) ifTrue: [ position := 0 @ 2 + position ]. (key anyMask: 8) ifTrue: [ position := 0 @ -2 + position ]. self center: position! ! !JPPlayer methodsFor: 'accessing' stamp: 'EiichiroIto 8/1/2011 20:49'! isCollidedWith: aPoint ^ false! ! !JPPlayer methodsFor: 'accessing' stamp: 'EiichiroIto 8/6/2011 14:16'! move self processKeys . self checkCollision! ! BorderedMorph subclass: #JPTreasure instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Itolab-JackPot'! !JPTreasure methodsFor: 'initialization' stamp: 'EiichiroIto 8/1/2011 20:50'! initialize super initialize. self borderWidth: 1. self extent: 8 @ 8. self color: Color yellow! ! !JPTreasure methodsFor: 'accessing' stamp: 'EiichiroIto 8/1/2011 20:54'! doWithPlayer: aPlayer | jackPot | jackPot := owner. self delete. jackPot gotTreasure! ! !JPTreasure methodsFor: 'accessing' stamp: 'EiichiroIto 8/1/2011 20:51'! isCollidedWith: aPoint ^ (self center dist: aPoint) < 8! ! !JPTreasure methodsFor: 'accessing' stamp: 'EiichiroIto 8/1/2011 20:54'! move ! !