Prev: 49045 Up: Map Next: 49196
49137: Update Ghost
The routine for objects of type 136 to 139, the ghosts. A ghost drifts towards the player and hurts the player if it touches. It vanishes when the player moves more than three cells away, and turns into a burst (scoring 16 hundred points) when a shot hits it.
UpdateGhost 49137 CALL PlayGhostSound Play the ghost's sound if the ghost has been drawn in the view.
49140 CALL SetVelocityTowardsPlayer Make the ghost drift towards the player.
49143 CALL SetDirectionFromVelocity Move the ghost.
49146 BIT 0,(IX+7) Jump to UpdateGhost_Burst if the ghost has been hit by something.
49150 JR NZ,UpdateGhost_Burst
49152 CALL MoveObject Check whether the ghost has run into the scenery.
49155 CALL NextSpriteNumber Animate the ghost.
49158 LD C,3 Set the distance at which the ghost gives up to 3 cells.
49160 CALL CheckPlayerClose Check whether the ghost is close to the player.
49163 JR NC,UpdateGhost_Vanish Jump to UpdateGhost_Vanish if the player is further away than that.
49165 CALL CheckShotHit Check whether a shot has hit the ghost.
49168 JR C,UpdateGhost_ShotBurst Jump to UpdateGhost_ShotBurst if it has.
49170 CALL CheckPlayerCollision Check whether the ghost is touching the player.
49173 RET NC Return if it is not.
49174 JP HurtPlayer Hurt the player (see HurtPlayer).
UpdateGhost_Vanish 49177 LD (IX+0),0 Remove the ghost, because the player has got away from it.
49181 RET Return.
A shot has hit the ghost.
UpdateGhost_ShotBurst 49182 LD (IY+0),12 Turn the shot that hit the ghost into a burst.
UpdateGhost_Burst 49186 LD (IX+0),12 Turn the ghost into a burst.
49190 LD BC,16 Set the points for destroying a ghost.
49193 JP AddToScore Jump to AddToScore to add the points to the score.
Prev: 49045 Up: Map Next: 49196