my hurt tile

Post Reply
User avatar
FrankenGraphics
Posts: 177
Joined: Wed Mar 07, 2018 11:36 am

my hurt tile

Post by FrankenGraphics » Sun May 12, 2019 1:06 pm

a simple addition, if you need one. detracts one life for player.

step 1:
-go to the handlePlayerHurt.asm your project is using. be aware that there may several copies named the same for different modules.

add this to the very top of the document

Code: Select all

hurtPlayer:
save.

step 2:
make a new text document.
paste the following

Code: Select all

cpx player1_object 
bne +
lda Object_timer_0,x
bne +
jsr hurtPlayer
+
save as myHurtTile.asm or whatever you'd like it to be named in an appropriate place.

Link up the new .asm file in script settings to a tile ID you want it to be.

Hurt tile properties:
-only hurts player
-player will recoil
-only detracts one life per hit/recoil period (checking object_timer_0,x guarantees this every time).
www.frankengraphics.com - NES homebrew blog
WillElm
Posts: 75
Joined: Wed Mar 20, 2019 3:56 am

Re: my hurt tile

Post by WillElm » Wed May 15, 2019 1:33 am

Thanks for this. I was trying to think of ways to do exactly this the other day. Of course I was over complicating it, this is nice and simple.
User avatar
rimoJO
Posts: 244
Joined: Sat Jan 12, 2019 2:23 am
Location: Planet Earth

Re: my hurt tile

Post by rimoJO » Sat Jun 15, 2019 12:49 pm

Thanks! I needed this!
Mystery Game status: Currently at least one in development. Stay tuned!
User avatar
SpiderDave
Posts: 15
Joined: Tue Jun 18, 2019 5:50 am

Re: my hurt tile

Post by SpiderDave » Thu Jul 18, 2019 6:47 am

You don't need to make a new label, and you're bypassing things like being lethal invincible. Here's what I use for spikes (I want them to hurt not kill).

spikes.asm

Code: Select all

    CPX player1_object
    BNE +

    lda #$01
    sta disableRecoil

    JSR doPlayerHurt
+
    LDA #TILE_SOLID
    STA tile_solidity
Set it up for one of your tile collision scripts. The last bit of code makes it solid.

In HandlePlayerHurt.asm, I added a check to disable recoil if "disableRecoil" is set.
You'll need to add the variable "disableRecoil". What it does is a one-time disable of recoil.

look for the line with:

Code: Select all

    JSR DetermineRecoilDirection
and change it to this:

Code: Select all

    lda disableRecoil
    bne +
    JSR DetermineRecoilDirection
+
    ; Turn it off automatically afterwards
    lda #$00
    sta disableRecoil
Post Reply