A C64 game - Step 20

posted in New Old Things
Published August 27, 2011
Advertisement

More refinement, this time with more impact on the gameplay. For one, the shotgun needs to be reloaded (stand still) and the collected items now also have an effect. Namely a new bullet slot and invincibility.



Adding the reload part is done with the following code piece. If the joystick is not moved and the player isn't waiting for the recoil to end the variable PLAYER_STAND_STILL_TIME is increased. Once it hits 40 frames one shell is added.

          ;check if player moved
          lda $dc00
          and #$1f
          cmp #$1f
          bne .PlayerMoved
          
          ;do not reload while recoil
          lda PLAYER_SHOT_PAUSE
          bne .PlayerMoved
          inc PLAYER_STAND_STILL_TIME
          lda PLAYER_STAND_STILL_TIME
          cmp #40
          bne .HandleFire
          
          ;reload
          lda #1
          sta PLAYER_STAND_STILL_TIME
          
          ;already fully loaded?
          lda PLAYER_SHELLS
          cmp PLAYER_SHELLS_MAX
          beq .HandleFire
          
          inc PLAYER_SHELLS
          
          ;display loaded shells
          ldy PLAYER_SHELLS
          lda #2
          sta SCREEN_COLOR + 23 * 40 + 18,y
          lda #7
          sta SCREEN_COLOR + 24 * 40 + 18,y

The other addition enhances the PickItem routine. Simply check the picked item type, and either add a new bullet slot or increase the player live counter.

!zone PickItem
PickItem
          lda ITEM_ACTIVE,y
          cmp #ITEM_BULLET
          beq .EffectBullet
          cmp #ITEM_HEALTH
          beq .EffectHealth
          
.RemoveItem
          lda #ITEM_NONE
          sta ITEM_ACTIVE,y
          lda #3
          jsr IncreaseScore
          jsr RemoveItemImage
          rts
          
.EffectBullet
          lda PLAYER_SHELLS_MAX
          cmp #5
          beq .RemoveItem
          
          ldx PLAYER_SHELLS_MAX
          lda #224
          sta SCREEN_CHAR + 23 * 40 + 19,x
          lda #225
          sta SCREEN_CHAR + 24 * 40 + 19,x
          lda #6
          sta SCREEN_COLOR + 23 * 40 + 19,x
          sta SCREEN_COLOR + 24 * 40 + 19,x
          inc PLAYER_SHELLS_MAX
          jmp .RemoveItem
          
.EffectHealth
          lda PLAYER_LIVES
          cmp #99
          beq .RemoveItem
          inc PLAYER_LIVES
          sty PARAM1
          jsr DisplayLiveNumber
          ldy PARAM1
          jmp .RemoveItem

step20.zip


Previous Step Next Step

Previous Entry A C64 game - Step 19
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement