Prev: 34200 Up: Map Next: 34282
34226: Check Player Touch
Checks whether an entity is touching the player. The player is touching an entity if the player is a character sprite (a sprite ID of 1 to 48), is in the same room and is within 11 pixels of it on both axes. When it touches, the byte at offset 2 of the player is set to 1 and the sound of touching is made.
Input
IX The entity to check
Output
E 1 if the player touches the entity, otherwise 0
CheckPlayerTouch 34226 LD A,(60049) Fetch the room of the player from PlayerRoom.
34229 LD E,0 Set the result in E to 0 (not touching).
34231 CP (IX+1) Compare the room of the player with the room of the entity.
34234 RET NZ Return if they are in different rooms.
34235 LD A,(60048) Fetch the sprite ID of the player from Player.
34238 AND A Test whether the player is in play.
34239 RET Z Return if not.
34240 CP 49 Return if the player is not a character sprite.
34242 RET NC
34243 LD A,(60051) Fetch the X position of the player from 60051.
34246 SUB (IX+3) Subtract the X position of the entity.
34249 JP P,CheckPlayerTouch_Test_X Jump to CheckPlayerTouch_Test_X if the difference is positive.
34252 NEG Make the difference positive.
CheckPlayerTouch_Test_X 34254 CP 12 Return if the player is too far away on the X axis.
34256 RET NC
34257 LD A,(60052) Fetch the Y position of the player from 60052.
34260 SUB (IX+4) Subtract the Y position of the entity.
34263 JP P,CheckPlayerTouch_Test_Y Jump to CheckPlayerTouch_Test_Y if the difference is positive.
34266 NEG Make the difference positive.
CheckPlayerTouch_Test_Y 34268 CP 12 Return if the player is too far away on the Y axis.
34270 RET NC
34271 LD A,1 Flag that the player has been touched.
34273 LD (60050),A
34276 CALL SoundsTouching Call SoundsTouching to make the sound of touching.
34279 LD E,1 Set the result in E to 1 (touching).
34281 RET Return.
Prev: 34200 Up: Map Next: 34282