• entries
    104
  • comments
    101
  • views
    255198

A C64 Game - Step 59

Sign in to follow this  
Endurion

1560 views

And yet another boss, this time a bit different than the previous two.

step59.png.24a9bffb34db470d6065db666a4a3b56.png

;------------------------------------------------------------
;boss 3
;------------------------------------------------------------
!zone BehaviourBoss3
BehaviourBoss3
          BOSS_MOVE_SPEED = 1
          lda SPRITE_HITBACK,x
          beq .NoHitBack
          dec SPRITE_HITBACK,x

          ldy SPRITE_HITBACK,x
          lda BOSS_FLASH_TABLE,y
          sta VIC_SPRITE_COLOR,x

          cpy #0
          bne .NoHitBack

          ;make vulnerable again
          ;lda SPRITE_STATE,x
          ;cmp #128
          ;bne .NoHitBack

          lda #0
          sta SPRITE_STATE,x

.NoHitBack
          lda DELAYED_GENERIC_COUNTER
          and #$01
          beq +

          rts

+
          ;y swing
          inc SPRITE_MOVE_POS_Y,x
          lda SPRITE_MOVE_POS_Y,x
          and #15
          sta SPRITE_MOVE_POS_Y,x

          ldy SPRITE_MOVE_POS_Y,x
          lda PATH_DY,y
          beq .NoYMoveNeeded
          sta PARAM1
          and #$80
          beq .MoveDown

          ;move up
          lda PARAM1
          and #$7f
          sta PARAM1
          
.MoveUp
          jsr ObjectMoveUp
          dec PARAM1
          bne .MoveUp

          jmp BossFollowPlayerX

.MoveDown
          jsr ObjectMoveDown
          dec PARAM1
          bne .MoveDown
          
.NoYMoveNeeded
          jmp BossFollowPlayerX


The boss is supposed to move quite alike the first boss horizontally. Time to make that code piece a sub routine:

!zone BossFollowPlayerX
BOSS3_MOVE_SPEED = 2
.DoGhostMove
          ;move X times
          ldy SPRITE_MOVE_POS,x
          sty PARAM4
          beq +

          lda SPRITE_DIRECTION,x
          beq .DoRight
.MoveLoopL
          jsr ObjectMoveLeftBlocking
          dec PARAM4
          bne .MoveLoopL
+
          rts

.DoRight
.MoveLoopR
          jsr ObjectMoveRightBlocking
          dec PARAM4
          bne .MoveLoopR
          rts
          
BossFollowPlayerX
          inc SPRITE_ANIM_DELAY,x
          lda SPRITE_ANIM_DELAY,x
          cmp #10
          beq .DoCheckMove
          jmp .DoGhostMove
.DoCheckMove
          lda #0
          sta SPRITE_ANIM_DELAY,x

          txa
          and #$01
          tay
          lda SPRITE_ACTIVE,y
          cmp #TYPE_PLAYER_DEAN
          beq .FoundPlayer
          cmp #TYPE_PLAYER_SAM
          beq .FoundPlayer

          ;check other player
          tya
          eor #1
          tay
          lda SPRITE_ACTIVE,y
          cmp #TYPE_PLAYER_DEAN
          beq .FoundPlayer
          cmp #TYPE_PLAYER_SAM
          beq .FoundPlayer

          ;no player to hunt
          rts

.FoundPlayer
          ;player index in y
          lda SPRITE_CHAR_POS_X,y
          cmp SPRITE_CHAR_POS_X,x
          bpl .MoveRight

          ;move left
          lda SPRITE_DIRECTION,x
          bne .AlreadyLookingLeft
          lda SPRITE_MOVE_POS,x
          beq .TurnLNow
          dec SPRITE_MOVE_POS,x
          bne .CheckXDone

.TurnLNow
          ;turning now
          lda #1
          sta SPRITE_DIRECTION,x
          lda #SPRITE_BOSS_ARM_L
          sta SPRITE_POINTER_BASE,x
          jmp .CheckXDone

.AlreadyLookingLeft
          lda SPRITE_MOVE_POS,x
          cmp #BOSS3_MOVE_SPEED
          beq .CheckXDone
          inc SPRITE_MOVE_POS,x
          jmp .CheckXDone

.MoveRight
          lda SPRITE_DIRECTION,x
          beq .AlreadyLookingRight

          lda SPRITE_MOVE_POS,x
          beq .TurnRNow
          dec SPRITE_MOVE_POS,x
          bne .CheckXDone

          ;turning now
.TurnRNow
          lda #0
          sta SPRITE_DIRECTION,x
          lda #SPRITE_BOSS_ARM_R
          sta SPRITE_POINTER_BASE,x
          jmp .CheckXDone

.AlreadyLookingRight
          lda SPRITE_MOVE_POS,x
          cmp #BOSS3_MOVE_SPEED
          beq .CheckXDone
          inc SPRITE_MOVE_POS,x
          jmp .CheckXDone


.CheckXDone
          rts


When the boss is hit he should be invulnerable for a short while, remember that we reserved the MSB in SPRITE_STATE for invincibility.

HitBehaviourBoss3
          lda #8
          sta SPRITE_HITBACK,x

          ;make invincible for a short while
          lda SPRITE_STATE,x
          ora #$80
          sta SPRITE_STATE,x
          rts


The rest boils down to the usual additions for a new object type.

Oh, and the new boss can only be hit if he shoots downwards! ;)

Have fun!

step59.zip

Previous Step Next Step

Sign in to follow this  


1 Comment


Recommended Comments

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now