mirror of
https://github.com/jeremysrand/BuGS.git
synced 2025-01-16 07:32:10 +00:00
Add some randomness when the spider changes direction.
This commit is contained in:
parent
213686ea1d
commit
18d0c3a80f
@ -37,6 +37,7 @@ SPIDER_RHS_TILE_OFFSET equ SPIDER_TOP_ROW_OFFSET+(GAME_NUM_TILES_WIDE-1)*SI
|
||||
SPIDER_STARTING_SHIFT equ 2
|
||||
SPIDER_LHS_STARTING_SCREEN_OFFSET equ SCREEN_BYTES_PER_ROW*SPIDER_STARTING_SHIFT+6
|
||||
|
||||
; Every four frames, change the spider sprite
|
||||
SPIDER_SPRITE_REFRESH_COUNT equ 4
|
||||
|
||||
|
||||
@ -366,7 +367,7 @@ updateSpider_tilesDown anop
|
||||
stx spiderTileOffsets+2
|
||||
lda tiles+TILE_BELOW_OFFSET,x
|
||||
cmp #INVALID_TILE_NUM
|
||||
beq updateSpider_offScreen
|
||||
beq updateSpider_tilesDownSkip
|
||||
sta spiderTileOffsets
|
||||
|
||||
ldx spiderTileOffsets+4
|
||||
@ -374,6 +375,8 @@ updateSpider_tilesDown anop
|
||||
lda tiles+TILE_BELOW_OFFSET,x
|
||||
sta spiderTileOffsets+4
|
||||
|
||||
; If the middle tile is a game time and it isn't empty, then
|
||||
; empty it. Spiders "consume" mushrooms as they pass over them.
|
||||
cpx #RHS_FIRST_TILE_OFFSET
|
||||
bge updateSpider_tilesDownCont
|
||||
lda tiles+TILE_TYPE_OFFSET,x
|
||||
@ -387,6 +390,13 @@ updateSpider_tilesDownCont anop
|
||||
lda tiles+TILE_BELOW_OFFSET,x
|
||||
sta spiderTileOffsets+8
|
||||
|
||||
updateSpider_tilesDownSkip anop
|
||||
lda spiderCurrentRow
|
||||
inc a
|
||||
sta spiderCurrentRow
|
||||
cmp spiderTargetRow
|
||||
beq updateSpider_offScreen
|
||||
|
||||
rtl
|
||||
|
||||
updateSpider_offScreen anop
|
||||
@ -437,6 +447,14 @@ addSpider entry
|
||||
lda #SPIDER_SPRITE_REFRESH_COUNT
|
||||
sta spiderSpriteRefresh
|
||||
|
||||
lda #SPIDER_TOP_ROW-1
|
||||
sta spiderCurrentRow
|
||||
|
||||
lda #SPIDER_NUM_POSSIBLE_ROWS-1
|
||||
jsl randN
|
||||
adc #SPIDER_TOP_ROW+1
|
||||
sta spiderTargetRow
|
||||
|
||||
addSpider_done anop
|
||||
rtl
|
||||
|
||||
@ -453,6 +471,9 @@ spiderScreenOffset dc i2'0'
|
||||
spiderScreenShift dc i2'0'
|
||||
spiderShiftInTile dc i2'0'
|
||||
|
||||
spiderCurrentRow dc i2'0'
|
||||
spiderTargetRow dc i2'0'
|
||||
|
||||
|
||||
; 10 6 2
|
||||
; 8 4 0
|
||||
|
@ -51,6 +51,7 @@ randInit_store16 anop
|
||||
|
||||
rtl
|
||||
|
||||
|
||||
; Returns a number from 0 to 14
|
||||
rand0_to_14 entry
|
||||
lda seed16
|
||||
@ -62,6 +63,21 @@ skipEor16 anop
|
||||
dec a
|
||||
rtl
|
||||
|
||||
; Returns a number from 0 to N-1 where N is <= 15, arrives in the accumulator
|
||||
randN entry
|
||||
cmp #2
|
||||
bge randN_doit
|
||||
lda #0
|
||||
rtl
|
||||
|
||||
randN_doit anop
|
||||
sta upperLimit
|
||||
randN_retry anop
|
||||
jsl rand0_to_14
|
||||
cmp upperLimit
|
||||
bge randN_retry
|
||||
rtl
|
||||
|
||||
|
||||
; Returns a number from 0 to 30
|
||||
rand0_to_30 entry
|
||||
@ -97,4 +113,6 @@ skipEor65535 anop
|
||||
seed65535 dc i2'0'
|
||||
seed32 dc i2'0'
|
||||
seed16 dc i2'0'
|
||||
|
||||
upperLimit dc i2'0'
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user