Prev: 56540 Up: Map Next: 56577
56544: Set Velocity From Speed
Sets the velocity of an object along the X and Y axes from its speed and the direction that it faces. Only one axis is used, and the velocity is negative for the directions that face down the screen and to the left.
Input
A Speed
IX Object
Put the speed on the X axis.
SetVelocityFromSpeed 56544 LD H,0 Make the speed the X velocity, with no Y velocity.
56546 LD L,A
56547 BIT 6,(IX+6) Jump to SetVelocityFromSpeed_Sign if the direction is along x.
56551 JR NZ,SetVelocityFromSpeed_Sign
Put the speed on the Y axis.
56553 LD H,A Make the speed the Y velocity, with no X velocity.
56554 LD L,0
Make the speed negative for down and left.
SetVelocityFromSpeed_Sign 56556 BIT 7,(IX+6) Jump to SetVelocityFromSpeed_Set unless the direction faces down the screen or to the left.
56560 JR Z,SetVelocityFromSpeed_Set
Negate the velocity along both axes.
56562 LD A,L Make the X velocity negative.
56563 NEG
56565 LD L,A
56566 LD A,H Make the Y velocity negative.
56567 NEG
56569 LD H,A
Store the velocities.
SetVelocityFromSpeed_Set 56570 LD (IX+10),L Set the X velocity of the object.
56573 LD (IX+11),H Set the Y velocity and return.
56576 RET
View the equivalent code in;
Prev: 56540 Up: Map Next: 56577