Prev: 47196 Up: Map Next: 47273
47205: Handle Ball Up Down
Handles a ball that bounces straight up and down. It falls until it hits the floor, then it rises at a speed of 3 until it reaches the top of its bounce, which is 32 above the height at which it was first seen, and starts to fall again.
Input
IX Address of the ball object
Work out the top of the bounce if it is not already stored.
HandleBallUpDown 47205 CALL SetPixelAdjustments_Ball Set the pixel adjustments of a ball.
47208 LD A,(23485) Fetch the height of the bounce from BallBounceHeight.
47211 AND A Test whether it has been worked out.
47212 JR NZ,HandleBallUpDown_Frame Jump to HandleBallUpDown_Frame if it has.
47214 LD A,(IX+3) Fetch the height of the ball.
47217 ADD A,32 Add 32 to get the height of the bounce.
47219 LD (23485),A Store it at BallBounceHeight.
Fall until the ball hits the floor, then rise.
HandleBallUpDown_Frame 47222 CALL ToggleGraphic Toggle the graphic of the ball between its two frames.
47225 CALL PlaySoundFromHeight Play the sound of a falling object.
47228 BIT 2,(IX+13) Jump to HandleBallUpDown_Rise if the ball is rising.
47232 JR NZ,HandleBallUpDown_Rise
47234 CALL ApplyGravityAndMove Apply gravity to the ball and move it.
47237 BIT 2,(IX+12) Jump to HandleBallUpDown_Draw if the ball has not hit the floor.
47241 JR Z,HandleBallUpDown_Draw
47243 SET 2,(IX+13) Flag the ball as rising.
47247 CALL PlayBumpSound Play the sound of a bounce.
HandleBallUpDown_Draw 47250 JR SetDeadlyFlagsAndDraw Make the ball deadly and flag it to be drawn again.
HandleBallUpDown_Rise 47252 LD (IX+11),3 Set the speed in Z to 3.
47256 CALL ApplyGravityAndMove Move the ball.
47259 LD A,(23485) Fetch the height of the bounce from BallBounceHeight.
47262 CP (IX+3) Compare it with the height of the ball.
47265 JR NC,HandleBallUpDown_Draw Jump to HandleBallUpDown_Draw if the ball is still below the top of the bounce.
47267 RES 2,(IX+13) Flag the ball as falling.
47271 JR HandleBallUpDown_Draw Jump to HandleBallUpDown_Draw.
Prev: 47196 Up: Map Next: 47273