Spawn enemy shots from right edge of screen.

This commit is contained in:
Colin McMillen 2015-05-31 18:03:46 -04:00
parent d81c9a9e4b
commit 526bc9e320

View File

@ -467,6 +467,7 @@ MaybeShootDone:
UpdateWorld: UpdateWorld:
jsr UpdateShotCooldown jsr UpdateShotCooldown
jsr SpawnEnemyShots
jsr UpdateShotPositions jsr UpdateShotPositions
jsr UpdateBackgroundScroll jsr UpdateBackgroundScroll
rts rts
@ -485,6 +486,38 @@ UpdateShotCooldown:
SpawnEnemyShots:
lda vBlankCounter
bit #%00111111
beq +
rts
+
lda #8 ; Sprite number.
sta enemyShotArray
lda #254
sta enemyShotArray + 1 ; x.
lda #((224 - 32) / 2)
and #%01111111
sta enemyShotArray + 2 ; y.
lda #-6
sta enemyShotArray + 3 ; x-velocity.
GetRandomByte
and #%00000111 ; [0, 7]
clc
adc #-3 ; [-3, 4]
cmp #4
bne +
lda #0 ; [-3, 3] with 2x chance of zero.
+
sta enemyShotArray + 4 ; y-velocity.
rts
UpdateShotPositions: UpdateShotPositions:
ldx #0 ldx #0
@ -553,7 +586,7 @@ ShotDone:
.rept shotSize .rept shotSize
inx inx
.endr .endr
cpx #(playerShotArrayLength * shotSize) cpx #(playerShotArrayLength * enemyShotArrayLength * shotSize)
bne UpdateShot bne UpdateShot
rts rts
@ -653,7 +686,7 @@ UpdateSprites:
.rept shotSize .rept shotSize
iny iny
.endr .endr
cpy #(playerShotArrayLength * shotSize) cpy #((playerShotArrayLength + enemyShotArrayLength) * shotSize)
bne - bne -
; Now clear out the unused entries in the sprite table. ; Now clear out the unused entries in the sprite table.