Prev: 52801 Up: Map Next: 53339
53238: Goldfish Game: Collision
Used by the routine at GoldfishGame.
The player has hit a sprite; test whether it is a fish or a creature.
GoldfishGame_Collision 53238 LD A,(56334) C=*GoldfishGame_PlayerAttributes.
53241 LD C,A
53242 LD A,(IX+0) A=the other sprite's horizontal co-ordinate.
53245 SUB (IX+7) Subtract the player's width at *GoldfishGame_PlayerWidth.
53248 INC A Increment A by one.
53249 SUB C Subtract the player column.
53250 CP 2 Jump to GoldfishGame_NextCreature if the sprites do not overlap.
53252 JR NC,GoldfishGame_NextCreature
53254 PUSH IX Stash the other sprite on the stack.
53256 LD HL,100 HL=0100.
53259 LD DE,100 DE=0100.
53262 CALL 949 Call BEEPER.
53265 POP IX Restore the other sprite from the stack.
53267 LD A,(IX+8) Jump to GoldfishGame_HitCreature if this sprite is not a collectable fish.
53270 CP 1
53272 JR NZ,GoldfishGame_HitCreature
The player has caught a fish; add it to the count and remove it from the screen.
GoldfishGame_CaughtFish 53274 LD A,(56130) Increment *GoldfishGame_FishCaught by one.
53277 INC A
53278 LD (56130),A
53281 LD C,(IX+0) C=the fish horizontal co-ordinate.
53284 LD B,(IX+1) B=the fish vertical co-ordinate.
53287 LD E,(IX+7) E=the fish width.
53290 LD D,(IX+8) D=the fish height.
53293 LD A,(IX+2) Jump to GoldfishGame_Collision_BlankSprite if the horizontal offset is 3.
53296 CP 3
53298 JR Z,GoldfishGame_Collision_BlankSprite
53300 INC E Widen the erase by one column.
GoldfishGame_Collision_BlankSprite 53301 LD HL,40812 Write 40812 to *CHARS.
53304 LD (23606),HL
53307 LD A,32 A=a blank character.
53309 CALL GoldfishGame_PrintSprite Erase the fish.
53312 LD (IX+10),0 Mark this fish slot inactive.
53316 JP GoldfishGame_NextCreature Jump to GoldfishGame_NextCreature.
A sea creature steals all collected fish.
GoldfishGame_HitCreature 53319 XOR A Clear *GoldfishGame_FishCaught.
53320 LD (56130),A
53323 PUSH IX Stash IX on the stack.
53325 LD HL,200 HL=0200.
53328 LD DE,50 DE=0050.
53331 CALL 949 Call BEEPER.
53334 POP IX Restore IX from the stack.
53336 JP GoldfishGame_NextCreature Jump to GoldfishGame_NextCreature.
Prev: 52801 Up: Map Next: 53339