Skip to navigation

Gameplay: ApplyTactics (Part 7 of 10)

Name: ApplyTactics (Part 7 of 10) [Show more] Type: Subroutine Category: Gameplay Summary: Rotate the enemy and make a rotation sound Deep dive: Enemy timers and state variables
Context: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
.tact16 LDX enemyObject \ Set X to the object number of the enemy to which we \ are applying tactics (so this is now object #X) LDA enemyRotateTimer,X \ If the rotation timer for the enemy is less than 2 CMP #2 \ then it has run all the way down, so jump to tact18 BCC tact18 \ to rotate the enemy .tact17 JMP MoveOnToNextEnemy \ Otherwise jump to MoveOnToNextEnemy to stop applying \ tactics to this enemy and set things up so we move on \ to the next enemy in the next iteration of the \ gameplay loop .tact18 \ If we get here then we need to rotate enemy #X TXA \ Check to see whether it is safe to redraw object #X JSR AbortWhenVisible \ without risk of corrupting a screen pan (if there is \ a risk and it can't be updated, then the call to \ AbortWhenVisible will not return here and will instead \ abort tactics for this iteration of the gameplay loop) LDA objectYawAngle,X \ Set objectYawAngle = objectYawAngle + enemyYawStep CLC \ ADC enemyYawStep,X \ So this rotates the enemy by the yaw angle in this STA objectYawAngle,X \ enemy's enemyYawStep variable LDA #200 \ Set enemyRotateTimer for the enemy to 200 so we wait STA enemyRotateTimer,X \ for 200 * 0.06 = 12 seconds before rotating the enemy \ again JSR ResetMeanieScan \ Reset the data stored for any meanie scans that the \ enemy has tried in the past, so the enemy can start \ looking for potential meanies with a clean slate LDX #7 \ Set X = 7 to pass to MakeSound-6 as the pitch of the \ first part of the rotating enemy sound LDY #120 \ Set Y = 70 to pass to MakeSound-6 as the pitch of the \ second part of the rotating enemy sound LDA #0 \ Make sound #0 (rotating enemy) with the pitches in X JSR MakeSound-6 \ and Y LDX enemyObject \ Set X to the object number of the enemy to which we \ are applying tactics JMP tact26 \ Jump to tact26 in part 10 to update object #X on the \ screen without a dithered effect, so the enemy rotates \ instantly if it is on-screen