This is the bullet behavior routine. It checks for collision before moving the bullet. This code is executed almost at the beginning of the game loop (only after controls):
Code: Select all
COLLISION_ENEMY_TEST_LOOP:
LDA BigEntType, Y ; find enemies to check for collision
CMP #EntityType::Enemy
BNE AFTER_ENEMY_TEST
STX arg1 ; store bullet's index in entity array
LDA #COLLISION_PLAYER_BULLET
STA arg2 ; store bullet's index in collision data array
STY arg3 ; store enemy's index in entity array
LDA #COLLISION_ENEMY_TYPE1
STA arg4 ; store enemy's index in collision data array
STX store_x
STY store_y
JSR CHECK_COLLISION ; check if collision happened (we don't do anything with it so far)
LDX store_x
LDY store_y
AFTER_ENEMY_TEST:
INY
TYA
;CMP #MAX_ENTITIES
;BEQ AFTER_COLLISION_TEST
;JMP COLLISION_ENEMY_TEST_LOOP
AFTER_COLLISION_TEST:
LDA BigEntYPos, X ; update bullet's y pos
SEC
SBC #$04
BCS :+
JSR DELETE_BIG_ENTITY
JMP AFTER_PLAYER_BULLET_BEHAVIOR
:
STA BigEntYPos, X
.endproc