![]() |
Routines |
| Prev: 25645 | Up: Map | Next: 25715 |
|
Checks whether a bug is touching the flower, using a window that is wider for a slug than it is for the midges and the leech. It also only counts when the bug is below the top of the flower.
|
||||||||||||||
| BugFlowerCollision | 25677 | LD E,0 | E=0 (no collision). | |||||||||||
| 25679 | LD HL,24205 | HL=State_Flower_Pos_X (the X position of the flower). | ||||||||||||
|
Calculate the horizontal distance between the flower and the bug.
|
||||||||||||||
| 25682 | LD A,(HL) | A=flower X position. | ||||||||||||
| 25683 | SUB (IX+1) | Subtract the bug X position. | ||||||||||||
| 25686 | ADD A,9 | Add 9 (so a bug up to 9 pixels to the right of the flower gives zero). | ||||||||||||
| 25688 | BIT 3,(IX+0) | Jump to BugFlowerCollision_Narrow if the bug is not a slug (bit 3 of the type is set for the midges and the leech). | ||||||||||||
| 25692 | JR NZ,BugFlowerCollision_Narrow | |||||||||||||
| 25694 | CP 36 | Compare A with 36 (the width of the window for a slug). | ||||||||||||
| 25696 | JR BugFlowerCollision_TestX | Jump to BugFlowerCollision_TestX. | ||||||||||||
| BugFlowerCollision_Narrow | 25698 | CP 28 | Compare A with 28 (the width of the window for the other bugs). | |||||||||||
| BugFlowerCollision_TestX | 25700 | RET NC | Return if the bug is too far away horizontally. | |||||||||||
|
Is the bug below the top of the flower?
|
||||||||||||||
| 25701 | INC HL | Increment HL by one to point to the flower Y position. | ||||||||||||
| 25702 | LD A,(HL) | Halve the flower Y position. | ||||||||||||
| 25703 | SRL A | |||||||||||||
| 25705 | LD D,(IX+2) | Halve the bug Y position into D. | ||||||||||||
| 25708 | SRL D | |||||||||||||
| 25710 | SUB D | Subtract the halved bug Y position from the halved flower Y position. | ||||||||||||
| 25711 | RET NC | Return if the flower is not above the bug. | ||||||||||||
| 25712 | LD E,1 | E=1 (collision). | ||||||||||||
| 25714 | RET | Return. | ||||||||||||
| Prev: 25645 | Up: Map | Next: 25715 |