CODE HELP! Stuck for weeks Death Animation.

TheRetroBro

Active member
So I've checked out the death animation thread by Dale and my original code is so different I don't know where to start.

Im.using the lr platformer module and when my player is it once he does and respawns at last warp or checkpoint (which is fine this is what I want). I created a death animation and assigned it to action step 6.

However my problem appears that wherever I put my "creat action step macro" in my code. The action steps appears AFTER my player reloads (not when I take damage)

So my player will get hit. Respawn then play the death animation. I'm at my wits end here. Please help.
Code:
;;;;;;;;;;;;;;;;;; Presumes there is a variable called myLives defined in user variables.
    ;;;;;;;;;;;;;;;;;; You could also create your own variable for this.

    LDA gameHandler
    AND #%10000000
    BEQ +canHurtPlayer
        JMP +skipHurt

+canHurtPlayer:
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;; is the monster below our feet?
    ;;;;;;;;;; and are we moving downward?
    
    LDA Object_v_speed_hi, x
    BEQ +doHurtPlayer ;; equal to zero
    BMI +doHurtPlayer ;; or negative
     ;; here we are moving downward.

    ; Check if there's an enemy below (assuming enemies have a specific object type).
    LDA Object_type, x
    CMP #$06 ;; Adjust the object type accordingly.
    BNE +doHurtPlayer ;; If the object below is not an enemy, proceed to hurting the player.

    TXA
    PHA
        LDX otherObject
        DestroyObject
        CountObjects #%00001000
            BNE +notZeroCount
                LDA scrollByte
                ORA #%00000010
                STA scrollByte
                ;;; if there are no more monsters left, we want to disable
                ;;; the edge check for scrolling.
                LDA ScreenFlags00
                AND #%11101111
                STA ScreenFlags00
            +notZeroCount
    PLA
    TAX

     ;; Do a hop
     LDA #$FC
     STA Object_v_speed_hi, x
    

     JMP +skipHurt

+doHurtPlayer
    PlaySound #sfx_index_sfx_laser
    Dec myLives
    LDA myLives
    BNE myLivesNotZero
        JMP RESET
            ;; game over.
        ;;WarpToScreen #$0, #01, #$01;;;; also could warp to game over screen here instead.
myLivesNotZero:
    ChangeActionStep player1_object, #$06 ;;; If I insert here it plays on reload
    LDA continueMap
    STA warpMap
    
    LDA continueX
    STA newX
    LDA continueY
    STA newY
    
    LDA continueScreen
    STA warpToScreen
    STA camScreen
    
    WarpToScreen warpToMap, warpToScreen, #$02

+skipHurt
 

smilehero65

Active member
So I've checked out the death animation thread by Dale and my original code is so different I don't know where to start.

Im.using the lr platformer module and when my player is it once he does and respawns at last warp or checkpoint (which is fine this is what I want). I created a death animation and assigned it to action step 6.

However my problem appears that wherever I put my "creat action step macro" in my code. The action steps appears AFTER my player reloads (not when I take damage)

So my player will get hit. Respawn then play the death animation. I'm at my wits end here. Please help.
Code:
;;;;;;;;;;;;;;;;;; Presumes there is a variable called myLives defined in user variables.
    ;;;;;;;;;;;;;;;;;; You could also create your own variable for this.

    LDA gameHandler
    AND #%10000000
    BEQ +canHurtPlayer
        JMP +skipHurt

+canHurtPlayer:
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;; is the monster below our feet?
    ;;;;;;;;;; and are we moving downward?
  
    LDA Object_v_speed_hi, x
    BEQ +doHurtPlayer ;; equal to zero
    BMI +doHurtPlayer ;; or negative
     ;; here we are moving downward.

    ; Check if there's an enemy below (assuming enemies have a specific object type).
    LDA Object_type, x
    CMP #$06 ;; Adjust the object type accordingly.
    BNE +doHurtPlayer ;; If the object below is not an enemy, proceed to hurting the player.

    TXA
    PHA
        LDX otherObject
        DestroyObject
        CountObjects #%00001000
            BNE +notZeroCount
                LDA scrollByte
                ORA #%00000010
                STA scrollByte
                ;;; if there are no more monsters left, we want to disable
                ;;; the edge check for scrolling.
                LDA ScreenFlags00
                AND #%11101111
                STA ScreenFlags00
            +notZeroCount
    PLA
    TAX

     ;; Do a hop
     LDA #$FC
     STA Object_v_speed_hi, x
  

     JMP +skipHurt

+doHurtPlayer
    PlaySound #sfx_index_sfx_laser
    Dec myLives
    LDA myLives
    BNE myLivesNotZero
        JMP RESET
            ;; game over.
        ;;WarpToScreen #$0, #01, #$01;;;; also could warp to game over screen here instead.
myLivesNotZero:
    ChangeActionStep player1_object, #$06 ;;; If I insert here it plays on reload
    LDA continueMap
    STA warpMap
  
    LDA continueX
    STA newX
    LDA continueY
    STA newY
  
    LDA continueScreen
    STA warpToScreen
    STA camScreen
  
    WarpToScreen warpToMap, warpToScreen, #$02

+skipHurt
Yeah, what is happening is that everything happens all at once.
Your player actually changes action step when his health is 0.

But, just a frame after that the Warp Code occur.
I use a death animation, too, and what I did was just comment out everything related to the warp
Code:
;LDA continueMap
    ;STA warpMap
   
    ;LDA continueX
    ;STA newX
    ;LDA continueY
    ;STA newY
   
    ;LDA continueScreen
    ;STA warpToScreen
    ;STA camScreen

Now, your action step will be changed... but now you won't warp.
So, set a timer in Action Step 06 and put the EndAction to GoToContinue.

That would be good...but there is an additional issue with scrolling, so you may follow this thread:


I think this would be necessary to set you up!
 

TheRetroBro

Active member
Yeah, what is happening is that everything happens all at once.
Your player actually changes action step when his health is 0.

But, just a frame after that the Warp Code occur.
I use a death animation, too, and what I did was just comment out everything related to the warp
Code:
;LDA continueMap
    ;STA warpMap
  
    ;LDA continueX
    ;STA newX
    ;LDA continueY
    ;STA newY
  
    ;LDA continueScreen
    ;STA warpToScreen
    ;STA camScreen

Now, your action step will be changed... but now you won't warp.
So, set a timer in Action Step 06 and put the EndAction to GoToContinue.

That would be good...but there is an additional issue with scrolling, so you may follow this thread:


I think this would be necessary to set you up!


Very good. I had done this earlier and that is exactly what happened. My player loaded in on the wrong area. Hmmm I may just concede to bot having a death animation for this game
 

smilehero65

Active member
Very good. I had done this earlier and that is exactly what happened. My player loaded in on the wrong area. Hmmm I may just concede to bot having a death animation for this game
Remember that in order for your character load in the level you're currently, you must put a checkpoint tile in the place where the player starts that level.
 

smilehero65

Active member
1709755790775.png
In 0C is where my checkpoint tile is placed, which is the same spot where my player appears when warping on this level.
 

TheRetroBro

Active member
Yeah, what is happening is that everything happens all at once.
Your player actually changes action step when his health is 0.

But, just a frame after that the Warp Code occur.
I use a death animation, too, and what I did was just comment out everything related to the warp
Code:
;LDA continueMap
    ;STA warpMap
  
    ;LDA continueX
    ;STA newX
    ;LDA continueY
    ;STA newY
  
    ;LDA continueScreen
    ;STA warpToScreen
    ;STA camScreen

Now, your action step will be changed... but now you won't warp.
So, set a timer in Action Step 06 and put the EndAction to GoToContinue.

That would be good...but there is an additional issue with scrolling, so you may follow this thread:


I think this would be necessary to set you up!
doing this caused me to not lose alife and respawn it acted like i was on life zero
 

dale_coop

Moderator
Staff member
Try with that Handle Player Hurt script:
Code:
;;;;;;;;;;;;;;;;;; Presumes there is a variable called myLives defined in user variables.
    ;;;;;;;;;;;;;;;;;; You could also create your own variable for this.

    LDA gameHandler
    AND #%10000000
    BEQ +canHurtPlayer
        JMP +skipHurt

+canHurtPlayer:
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;; is the monster below our feet?
    ;;;;;;;;;; and are we moving downward?
  
    LDA Object_v_speed_hi, x
    BEQ +doHurtPlayer ;; equal to zero
    BMI +doHurtPlayer ;; or negative
     ;; here we are moving downward.

    ; Check if there's an enemy below (assuming enemies have a specific object type).
    LDA Object_type, x
    CMP #$06 ;; Adjust the object type accordingly.
    BNE +doHurtPlayer ;; If the object below is not an enemy, proceed to hurting the player.

    TXA
    PHA
        LDX otherObject
        DestroyObject
        CountObjects #%00001000
            BNE +notZeroCount
                LDA scrollByte
                ORA #%00000010
                STA scrollByte
                ;;; if there are no more monsters left, we want to disable
                ;;; the edge check for scrolling.
                LDA ScreenFlags00
                AND #%11101111
                STA ScreenFlags00
            +notZeroCount
    PLA
    TAX

     ;; Do a hop
     LDA #$FC
     STA Object_v_speed_hi, x
  

     JMP +skipHurt

+doHurtPlayer
    PlaySound #sfx_index_sfx_laser
    Dec myLives

    ChangeActionStep player1_object, #$06 ;;; If I insert here it plays on reload

    ;; stop the scrolling:
    LDA scrollByte
    AND #%00111110
    ORA #%00000010
    STA scrollByte

    ;; stop the player:
    LDA #$00
    STA Object_h_speed_hi,x
    STA Object_h_speed_lo,x
    STA Object_v_speed_hi,x
    STA Object_v_speed_lo,x
    LDA xPrev
    STA Object_x_hi,x
    LDA yPrev
    STA Object_y_hi,x
  
    ;; and disables the inputs:
    LDA #$FF
    STA gameState       

+skipHurt

You need to set your Player's Action Step 6 EndAnimation to "GoToContinue" (and set the EndAction to "loop").
2024-03-07 13_16_41-Monster Animation Info.png
(note: of course, if prefer using the EndAction for the "GoToContinue" it works too, make sure to set a timer in that case)

And now we'll modify that GoToContinue action to check the lives to warp to the last checkpoint or the game over screen if no more lives.

Edit the TimerEndScripts.asm script that is located in the "Game\Subroutines" subfolder. Search for the "goToContinue_action:" section. And replace with that one:
Code:
;;; 09 = Go To Continue
goToContinue_action:
        ;; if no more lives, warp to GAME OVER:
         LDA myLives
        BEQ +notMoreLives
        BMI +notMoreLives
            ;; player still have lives, warp to last checkpoint:
            LDA continueMap
            STA warpToMap
            LDA continueScreen
            STA warpToScreen
            LDA #$02
            STA screenTransitionType     
            JMP +doWarpToContinue
    +notMoreLives:
            ;; no more lives:
            LDA #$01              ;; <-- map 00: Overworld, 01: Underworld
            STA warpToMap
            LDA #$02              ;; <-- screen Y:0, X:2 (your GAME OVER screen)
            STA warpToScreen
            LDA #$01
            STA screenTransitionType     
    +doWarpToContinue:
        LDA myMaxHealth
        STA myHealth
        WarpToScreen warpToMap, warpToScreen, screenTransitionType
        ChangeActionStep player1_object, #$00
        LDX player1_object
        LDA #FACE_RIGHT
        STA Object_direction,x
    RTS
 

NightMusic

Member
Yeah, what is happening is that everything happens all at once.
Your player actually changes action step when his health is 0.

But, just a frame after that the Warp Code occur.
I use a death animation, too, and what I did was just comment out everything related to the warp
Code:
;LDA continueMap
    ;STA warpMap
  
    ;LDA continueX
    ;STA newX
    ;LDA continueY
    ;STA newY
  
    ;LDA continueScreen
    ;STA warpToScreen
    ;STA camScreen

Now, your action step will be changed... but now you won't warp.
So, set a timer in Action Step 06 and put the EndAction to GoToContinue.

That would be good...but there is an additional issue with scrolling, so you may follow this thread:


I think this would be necessary to set you up!
I have the problem when my player dies if its set to "gotoContinue" (timerendscripts) when the player dies and odes the animation they fall endlessly... its so odd. @dale_coop has anyone you know of reported this ?
 

smilehero65

Active member
I have the problem when my player dies if its set to "gotoContinue" (timerendscripts) when the player dies and odes the animation they fall endlessly... its so odd. @dale_coop has anyone you know of reported this ?
Now that's odd... do you have your Ignore Gravity flag checked?
Can you show some footage of the problem?
 
Top Bottom