Jump to content

  • Log In with Google      Sign In   
  • Create Account





A C64 Game - Step 59

Posted by Endurion, in C64 07 July 2012 · 863 views

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

Attached Image

;------------------------------------------------------------
;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!


Previous Step Next Step

Attached Files






I really need to get a C64 emulator to try this (I got one but for some reason it doesn't even boot... I need to find out what's going on)

December 2014 »

S M T W T F S
 123456
78910111213
14151617181920
21222324252627
28 293031   
PARTNERS