Prev: 49597 Up: Map Next: 49670
49605: Run Projectile
The handler of the object types 149 to 151, which are the three sprites of a projectile that is in flight, and of 60. 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 132 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 49605 CALL SetSpriteOffset_Minus12_Minus6 Call SetSpriteOffset_Minus12_Minus6 to set where the sprite is drawn.
49608 CALL ApplyGravityAndMove Call ApplyGravityAndMove to move the projectile.
49611 LD A,(IX+0) Fetch the type of the projectile, and take one away to get the next sprite.
49614 DEC A
49615 CP 148 Jump to RunProjectile_SetType unless that gives 148, which is not a sprite of a projectile.
49617 JR NZ,RunProjectile_SetType
49619 LD A,151 Use the sprite 151 instead.
Keep the projectile at least 132 up.
RunProjectile_SetType 49621 LD (IX+0),A Set the type of the projectile.
49624 LD A,(IX+3) Jump to RunProjectile_TestHit if the projectile is at least 132 up.
49627 CP 132
49629 JR NC,RunProjectile_TestHit
49631 LD (IX+3),132 Put the projectile at a height of 132.
49635 LD (IX+11),0 Stop it from falling.
Explode on a creature or a wall, else keep flying.
RunProjectile_TestHit 49639 CALL TestCreatureHit Call TestCreatureHit to find out if the projectile touches a creature.
49642 LD A,D Fetch the result.
49643 AND A Jump to ScoreForCreature if it does.
49644 JP Z,ScoreForCreature
49647 LD A,(IX+12) Fetch the collision flags of the projectile.
49650 AND %00000011 Keep only the bits for a hit along x or y.
49652 JP NZ,StartExplosion Jump to StartExplosion to explode if the projectile hit a wall.
49655 LD A,(IX+20) Set the x speed of the projectile to the speed that it was fired with.
49658 LD (IX+9),A
49661 LD A,(IX+21) Set the y speed of the projectile to the speed that it was fired with.
49664 LD (IX+10),A
49667 JP SetWipeAndDrawFlags Jump to SetWipeAndDrawFlags to mark the projectile to be drawn.
Prev: 49597 Up: Map Next: 49670