Prev: C1BD Up: Map Next: C206
C1C5: Run Projectile
The handler of the object types 95 to 97, which are the three sprites of a projectile that is in flight, and of 3C. Each time that it is run the projectile moves on one place, and changes type to the next of the three sprites.
The projectile flies at least 84 up, and does not fall. It explodes if it hits a wall, and if it hits one of the creatures then the player scores for it and the creature explodes instead.
Input
IX Record of the projectile
Move the projectile and cycle its sprite.
RunProjectile C1C5 CALL SetSpriteOffset_Minus12_Minus6 Call SetSpriteOffset_Minus12_Minus6 to set where the sprite is drawn.
C1C8 CALL ApplyGravityAndMove Call ApplyGravityAndMove to move the projectile.
C1CB LD A,(IX+$00) Fetch the type of the projectile, and take one away to get the next sprite.
C1CE DEC A
C1CF CP $94 Jump to RunProjectile_SetType unless that gives 94, which is not a sprite of a projectile.
C1D1 JR NZ,RunProjectile_SetType
C1D3 LD A,$97 Use the sprite 97 instead.
Keep the projectile at least 84 up.
RunProjectile_SetType C1D5 LD (IX+$00),A Set the type of the projectile.
C1D8 LD A,(IX+$03) Jump to RunProjectile_TestHit if the projectile is at least 84 up.
C1DB CP $84
C1DD JR NC,RunProjectile_TestHit
C1DF LD (IX+$03),$84 Put the projectile at a height of 84.
C1E3 LD (IX+$0B),$00 Stop it from falling.
Explode on a creature or a wall, else keep flying.
RunProjectile_TestHit C1E7 CALL TestCreatureHit Call TestCreatureHit to find out if the projectile touches a creature.
C1EA LD A,D Fetch the result.
C1EB AND A Jump to ScoreForCreature if it does.
C1EC JP Z,ScoreForCreature
C1EF LD A,(IX+$0C) Fetch the collision flags of the projectile.
C1F2 AND %00000011 Keep only the bits for a hit along x or y.
C1F4 JP NZ,StartExplosion Jump to StartExplosion to explode if the projectile hit a wall.
C1F7 LD A,(IX+$14) Set the x speed of the projectile to the speed that it was fired with.
C1FA LD (IX+$09),A
C1FD LD A,(IX+$15) Set the y speed of the projectile to the speed that it was fired with.
C200 LD (IX+$0A),A
C203 JP SetWipeAndDrawFlags Jump to SetWipeAndDrawFlags to mark the projectile to be drawn.
Prev: C1BD Up: Map Next: C206