Death in the underword fix? 4.5.9

TheRetroBro

Active member
I noticed dieing in the underworld warps me back to the associated tile from the overworld

Is there a fox for this?
 

baardbi

Well-known member
I noticed dieing in the underworld warps me back to the associated tile from the overworld

Is there a fox for this?
It would help if you could post the hurt/death script. The warp map needs to be 1 in order to warp to the underworld. So you need to make sure in your death code, it is set up like this:

LDA #1 ;;; Underworld
STA warpToMap

warpToMap 0 = Overworld
warpToMap 1 = Underworld
 

TheRetroBro

Active member
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:

    LDA continueMap
    STA warpMap
    
    LDA continueX
    STA newX
    LDA continueY
    STA newY
    
    LDA continueScreen
    STA warpToScreen
    STA camScreen
    
    WarpToScreen warpToMap, warpToScreen, #$02

+skipHurt

Here is the code> Also important to note im having alot of trouble adding a player death animation.

Also a game over screen. I took away the JMp reset and added a warp macro there but the screen just freezes. Honestly just not sure what Im doing wrong with this one!
 

dale_coop

Moderator
Staff member
When you die, you respawn at your previous checkpoint
Make sure you have a correcr checkpoint script and also that you placed a checkpoint tile at strategic places (usually the beginning of your levels).

Also, if you're not using checkpoints and you're starting your game from a screen on the underworld map, you need to modify the Initialization script.
Search for the "STA warpMap" line and AFTER that line add:
Code:
STA continueMap
 

TheRetroBro

Active member
When you die, you respawn at your previous checkpoint
Make sure you have a correcr checkpoint script and also that you placed a checkpoint tile at strategic places (usually the beginning of your levels).

Also, if you're not using checkpoints and you're starting your game from a screen on the underworld map, you need to modify the Initialization script.
Search for the "STA warpMap" line and AFTER that line add:
Code:
STA continueMap
ha yeah i had started my player in my underworld to test out the area and now realize this was the issue when dieing! oops lol slight oversite by me!
 
Top Bottom