← CEB3 Hive behavior handler Map D00C → Capsule behavior handler
CFB1: Bee behavior handler
Per-frame handler for the bee, which flies horizontally toward the bat's losing edge and stings on contact. A sting freezes the player's control of the bat until the player loses the last ball or the next level starts.
Input
IX the bee's sprite record
IY the bee's logic record
C the bee's pool-slot index
Two bees can be live at once, because only the hive checks whether one is already alive. A wave script can place a bee past that check.
update_bee CFB1 CALL inhabitant_react_state Reaction-state machine first; carry means skip this frame.
CFB4 RET C
CFB5 LD HL,anim_bee Run the bee animation, and wrap at its last frame.
CFB8 CALL advance_anim
CFBB LD A,(IY+$0B)
CFBE CP $02
CFC0 JR C,bee_home
CFC2 LD (IY+$0B),$00
Home on the bat's losing edge. The heading is rightward when the bat is on the right and leftward when it is on the left. Then advance one step. The bee tracks whichever wall the bat occupies.
bee_home CFC6 LD A,(bat_side) Bat on the right: take the rightward heading.
CFC9 OR A
CFCA JR NZ,bee_aim_alt
CFCC LD A,$02
CFCE JR bee_set_heading
bee_aim_alt CFD0 LD A,$06 Bat on the left: take the leftward heading instead.
bee_set_heading CFD2 LD (IY+$00),A Commit the heading and advance one step toward the bat's losing edge.
CFD5 CALL move_object
CFD8 CALL inhabitant_offscreen Despawn off the far edge; carry means gone.
CFDB RET C
CFDC LD B,$0A Award 100 points if a ball hits it. Carry means killed.
CFDE CALL ball_kill
CFE1 RET C
CFE2 LD A,C Name this inhabitant (its slot in C) as the first overlap operand.
CFE3 LD (overlap_slot_1),A
CFE6 XOR A Name the bat as the second overlap operand.
CFE7 LD (overlap_slot_2),A
bee_check_bat CFEA CALL overlap_pair Reached the bat?
CFED OR A
CFEE JR Z,bee_sweep
bee_sting CFF0 LD (IY+$0B),$00 Yes: restart the animation and die.
CFF4 LD (IY+$0C),$02
CFF8 LD A,$01 Raise the sting freeze: the player loses control of the bat.
CFFA LD (bat_sting_freeze),A
CFFD RET
The sweep's window sits a pixel the other way from the bat test above. A bee that arrives exactly 12 px below or right of the bat is killed against it, and no sting happens.
bee_sweep CFFE CALL overlap_sweep No sting: the sweep still takes it in a plain kill.
D001 OR A
D002 RET Z
D003 LD (IY+$0B),$00 Restart the animation and die.
D007 LD (IY+$0C),$02
D00B RET
← CEB3 Hive behavior handler Map D00C → Capsule behavior handler
Fork me on GitHub