Browse Source

Make an explicit cooldown for spawning the next ship.

main
Colin McMillen 9 years ago
parent
commit
a387160fdd
  1. 2
      memory.asm
  2. 18
      pewpew.asm

2
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

18
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.
-

Loading…
Cancel
Save