[4.5.9] Player's Death Animation, Checkpoints and Game Over screen (metroVania module)

offparkway

Active member
Can you share that script?
was already grabbing it for you!
Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;SWAP PLAYER
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

canSwitchPlayer:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
LDA haveDill ;;did you unlock Dill?
BNE +
  RTS
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

TXA
PHA
;; first, we will store every placement informations about the player

LDX player1_object
LDA Object_x_hi,x ;; the current horizontal position
    ; CLC
    ; ADC #$04
STA tempA
LDA Object_y_hi,x ;; the current vertical position
    ; CLC
    ; ADC #$04
STA tempB
     LDA Object_direction,x ;; the current facing and movements
    ; AND #%00000111
     STA tempC

;; now, depending of the current object used by the player:
;; we can switch to the new object, or switch back the normal one

LDA Object_type,x
BNE changeIntoNormal
    LDA #15 ;; <-- HERE ! the new player object to transform into - DILL
    STA tempPlayer
        LDA #$03 ;; Frisbee
        STA currentWeapon
        WEAPON_SPRITE_0 = #$75
    JMP continueChangePlayerInto
changeIntoNormal:
    LDA #00 ;; the normal player object - JIM
    STA tempPlayer
        LDA #$01 ;; Rock
        STA currentWeapon
        WEAPON_SPRITE_0 = #$75
continueChangePlayerInto:

DestroyObject ;; we destroy the current object
CreateObject tempA, tempB, tempPlayer, #$00 ;; and create the new one


TXA
STA player1_object ;; store that new created object in the Player 1 var
STA camObject
    ; LDA tempC ;; set back the player directions
    ; STA Object_direction,x
PLA
TAX


doneSwitchingPlayer2:   
    RTS
 

dale_coop

Moderator
Staff member
I haven’t tested it but the script looks correct 👍

What happens if you use that character switch script before touching the checkpoint tile…?
Does the checkpoint work ?
 

AntwonVinnie

New member
Hey Dale, great tutorial! Was wondering if you knew anything about this issue I’m having with the check point tiles and game over screen. I’m working in Metroidvania 4.5.9 and the instant my player collides with a checkpoint tile, it turns that space into a tile from my background tile sheets. The checkpoint works as normal gladly but it’s just a visual glitch. I was also wondering why my character isn’t warping to game over after losing all their lives. It just restarts at the beginning of the game, which is also a good sign, so I must just be missing something small. Your tutorial helped me learn a bit more about assembly language so thanks for that. Looking forward to hearing back and thanks for all the help. I’ll provide pics and code if you need more info
 

dale_coop

Moderator
Staff member
@AntwonVinnie About the checkpoint tile, modify the checkpoint tile script, around the end you should see:
Code:
ChangeTileAtCollision #$00, #$00
Remove or comment out that line (adding ";" at the begining of the line)
Now your checkpoint tile should not be replaced by a background tile.

For your restart game when you die... maybe it's your Handle Player Death tha tis incorrect.
Are you diying from a collision with a monster or with a hurt/death tile ?
 

AntwonVinnie

New member
@AntwonVinnie About the checkpoint tile, modify the checkpoint tile script, around the end you should see:
Code:
ChangeTileAtCollision #$00, #$00
Remove or comment out that line (adding ";" at the begining of the line)
Now your checkpoint tile should not be replaced by a background tile.

For your restart game when you die... maybe it's your Handle Player Death tha tis incorrect.
Are you diying from a collision with a monster or with a hurt/death tile ?
Ok that checkpoint fix makes sense to me! I’ll try it out and let you know. And with the restart, I’m currently testing it with hurt tiles. I set up a couple monsters but haven’t tested them yet but I’ll do that too. Is there any code I should send your way?
 

AntwonVinnie

New member
Ok cool so I got the check point tiles to work, very easy and I see how the code works for that now. So I put a monster on my start screen and the death animation works perfectly, and after losing 3 lives I get sent to game over screen. No problem, but the problem is if my player hits a hurt tile (ex: spikes, drop) It never sends me to the game over screen, even if I lose all 3 lives. (Also, no death animation plays after hitting hurt tile, hmmm) Where can I modify handle player death?
 

AntwonVinnie

New member
@AntwonVinnie Oh sure. I see.. Can you share your hurt tile script ?
here is the script

;;; Simple Reset
;; check to see if object colliding is a player.
;; if not, do not reset.
CPX player1_object
BNE dontDoTileReset
LDA Object_direction,x
AND #%00001111
STA Object_direction,x

Dec myLives
LDA myLives
BNE +myLivesNotZero
JMP RESET ;; game over.
;;;; also could warp to game over screen here instead.
+myLivesNotZero:

LDA continueMap
STA warpMap

LDA continueX
STA newX
LDA continueY
STA newY

LDA continueScreen
STA warpToScreen
STA camScreen


ok! I see the JMP RESET with the comment about the game over screen, but not knowing what to write in ASM language is keeping me from making those tiles go to the game over screen. so not sure what to write.
 

dale_coop

Moderator
Staff member
here is the script

Try to replace all the code with that one:
Code:
;;; Simple Death Tile
;; check to see if object colliding is a player.
CPX player1_object
BEQ +canHurtPlayer
    ;; make it solid for the other objects:
    LDA ObjectUpdateByte
    ORA #%00000001
    STA ObjectUpdateByte ;; makes solid 
    JMP +endScript
+canHurtPlayer:
    LDA gameState
    CMP #$FF
    BNE +continue
        JMP +endScript
    +continue:
    ;; recoil
    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
    LDA Object_direction,x
    AND #%00001111
    STA Object_direction,x
    ;; player is dead, we play the death state:
    ChangeActionStep player1_object, #$06
    
    ;; stop the scrolling :
    LDA scrollByte
    AND #%00111110
    ORA #%00000010
    STA scrollByte
    ;; and disables the inputs:
    LDA #$FF
    STA gameState
+endScript:
RTS
 

AntwonVinnie

New member
Try to replace all the code with that one:
Code:
;;; Simple Death Tile
;; check to see if object colliding is a player.
CPX player1_object
BEQ +canHurtPlayer
    ;; make it solid for the other objects:
    LDA ObjectUpdateByte
    ORA #%00000001
    STA ObjectUpdateByte ;; makes solid
    JMP +endScript
+canHurtPlayer:
    LDA gameState
    CMP #$FF
    BNE +continue
        JMP +endScript
    +continue:
    ;; recoil
    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
    LDA Object_direction,x
    AND #%00001111
    STA Object_direction,x
    ;; player is dead, we play the death state:
    ChangeActionStep player1_object, #$06
   
    ;; stop the scrolling :
    LDA scrollByte
    AND #%00111110
    ORA #%00000010
    STA scrollByte
    ;; and disables the inputs:
    LDA #$FF
    STA gameState
+endScript:
RTS
AWESOME! That did the trick :) death animation plays and 3 lives lost goes to game over! many thanks!!!
 
Top Bottom