• entries
    104
  • comments
    101
  • views
    255225

A C64 Game - Step 44

Sign in to follow this  
Endurion

1721 views

And yet more enemies, an underground hand and a devil skeleton. Nothing spectacularely new.

step44.png

The devil skeleton is behaving mostly like the mummy. Walk back and forth, if a player is seen, speed towards him.

!zone BehaviourDevil
BehaviourDevil
          lda SPRITE_HITBACK,x
          beq .NoHitBack
          dec SPRITE_HITBACK,x
          lda SPRITE_HITBACK_DIRECTION,x
          beq .HitBackRight

          ;move left
          jsr ObjectMoveLeftBlocking
          rts

.HitBackRight
          jsr ObjectMoveRightBlocking
          rts

.NoHitBack
          jsr ObjectMoveDownBlocking
          beq .NotFalling
          rts

.NotFalling
          inc SPRITE_ANIM_DELAY,x
          lda SPRITE_ANIM_DELAY,x
          cmp #8
          bne .NoAnimUpdate

          lda #0
          sta SPRITE_ANIM_DELAY,x

          inc SPRITE_ANIM_POS,x
          lda SPRITE_ANIM_POS,x
          cmp #3
          bne .NoWrap
          lda #0
.NoWrap
          sta SPRITE_ANIM_POS,x

          clc
          asl
          adc SPRITE_DIRECTION,x
          adc #SPRITE_DEVIL_WALK_R_1
          sta SPRITE_POINTER_BASE,x
.NoAnimUpdate
          lda SPRITE_CHAR_POS_Y,x
          cmp SPRITE_CHAR_POS_Y
          bne .NoPlayerInSight

          ;player on same height
          ;looking at the player?
          jsr LookingAtPlayer
          beq .NoPlayerInSight
          lda SPRITE_DIRECTION,x
          beq .AttackRight

          ;attack to left
          jsr ObjectMoveLeftBlocking
          jsr ObjectMoveLeftBlocking
          beq .ToggleDirection
          rts

.AttackRight
          ;attack to left
          jsr ObjectMoveRightBlocking
          jsr ObjectMoveRightBlocking
          beq .ToggleDirection
          rts
          
.NoPlayerInSight
          lda DELAYED_GENERIC_COUNTER
          and #$03
          beq .MovementUpdate
          rts

.MovementUpdate
          inc SPRITE_MOVE_POS,x
          lda SPRITE_MOVE_POS,x
          and #$03
          sta SPRITE_MOVE_POS,x

          lda SPRITE_DIRECTION,x
          beq .MoveRight

          ;move left
          jsr ObjectWalkLeft
          beq .ToggleDirection
          rts

.MoveRight
          jsr ObjectWalkRight
          beq .ToggleDirection
          rts

.ToggleDirection
          lda SPRITE_DIRECTION,x
          eor #1
          sta SPRITE_DIRECTION,x
          clc
          adc #SPRITE_DEVIL_WALK_R_1
          sta SPRITE_POINTER_BASE,x
          rts



The hand is a bit more interesting. It is stationary, but usually stays underground. In intervals the hand rises and tries to grab at the player.

;------------------------------------------------------------
;simply appear and hide again
;state 128 = invisible
; 0 = rising/hiding
;------------------------------------------------------------
!zone BehaviourHand
BehaviourHand
          lda DELAYED_GENERIC_COUNTER
          and #$03
          beq .MovementUpdate
.NoMovement
          rts
          
.MovementUpdate
          lda SPRITE_STATE,x
          bne .HiddenState
          inc SPRITE_ANIM_DELAY,x
          lda SPRITE_ANIM_DELAY,x
          cmp #3
          bne .NoMovement

          lda #0
          sta SPRITE_ANIM_DELAY,x

          inc SPRITE_ANIM_POS,x
          lda SPRITE_ANIM_POS,x
          cmp #6
          beq .EnterHiddenState

.UpdateHandSprite
          ldy SPRITE_ANIM_POS,x
          lda HAND_ANIM_TABLE,y
          sta SPRITE_POINTER_BASE,x
          lda HAND_COLOR_TABLE,y
          sta VIC_SPRITE_COLOR,x
          rts

.EnterHiddenState
          lda #SPRITE_INVISIBLE
          sta SPRITE_POINTER_BASE,x

          jsr GenerateRandomNumber
          sta SPRITE_MOVE_POS,x

          lda #128
          sta SPRITE_STATE,x
.StillHidden
          rts

.HiddenState
          dec SPRITE_MOVE_POS,x
          bne .StillHidden

          ;unhiding
          lda #0
          sta SPRITE_STATE,x
          sta SPRITE_ANIM_DELAY,x
          sta SPRITE_ANIM_POS,x
          jmp .UpdateHandSprite 


Note that also for the hand the empty sprite comes to use. It's basically an empty image to avoid disabling and enabling the sprite. This however comes at the cost of 63 bytes for the image.

step44.zip

Previous Step Next Step

Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

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