diff --git a/memory.asm b/memory.asm index c63d41d..33a4a73 100644 --- a/memory.asm +++ b/memory.asm @@ -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 diff --git a/pewpew.asm b/pewpew.asm index 0fadb6f..c2e5d43 100644 --- a/pewpew.asm +++ b/pewpew.asm @@ -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. -