Make an explicit cooldown for spawning the next ship.

This commit is contained in:
Colin McMillen 2015-06-06 18:14:20 -04:00
parent c17b137ab2
commit a387160fdd
2 changed files with 17 additions and 3 deletions

View File

@ -10,6 +10,7 @@
; 0022: player health.
; 0023: shot cooldown timer.
; 0024: next-shot state.
; 0025: number of frames until the next enemy ship spawns.
; [gap]
; 0030-003F: (x, y) velocities of each of the 8 possible shot states.
; 0040-009F: {sprite, x, y, x-velocity, y-velocity, unused} per player shot.
@ -34,6 +35,7 @@
.define playerHealth $22
.define shotCooldown $23
.define nextShotState $24
.define enemyShipSpawnCooldown $25
.define shotVelocityTable $30
.define playerShotArray $40
.define playerShotArrayLength 16

View File

@ -218,6 +218,10 @@ InitWorld:
lda #4
sta backgroundBlue
; Initial enemy ship-spawn cooldown.
lda #30
sta enemyShipSpawnCooldown
; Player's initial starting location and health.
lda #(256 / 4)
sta playerX
@ -498,11 +502,19 @@ UpdateShotCooldown:
SpawnEnemyShips:
GetRandomByte
bit #%01111111 ; Spawn ships every this-many frames (on average).
lda enemyShipSpawnCooldown
cmp #0
beq +
dec A
sta enemyShipSpawnCooldown
rts
+
GetRandomByte
and #%00111111
clc
adc #32
sta enemyShipSpawnCooldown
; Find an empty spot in the array.
ldy #0
-
@ -520,7 +532,7 @@ SpawnEnemyShips:
lda #4 ; Sprite number.
sta enemyShipArray, Y
lda #(256 - 32)
lda #254
sta enemyShipArray + 1, Y ; x.
-