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

View File

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