Instant Death with Lives (NESmaker 4.5)

TolerantX

Active member
This is a buggy code I tried to adapt, but really lost patience and wanted to move on to another code at the time.
(It works but not as intended... sometimes it auto-kills the player after resurrection... not good.)

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:
	
	
	Dec myLives
	LDA myLives
	BNE myLivesNotZeroes
		JMP RESET ;; game over.
		;;;; also could warp to game over screen here instead.
myLivesNotZeroes:

	LDA continueMap
	STA warpMap
	
	LDA continueScreen
	STA currentNametable
	
	LDX player1_object
	STA Object_screen,x
	
	LDA #$02 ;; this is continue type warp.
	STA screenTransitionType ;; is of warp type

	
	LDA gameHandler
	ORA #%10000000
	STA gameHandler ;; this will set the next game loop to update the screen.

+skipHurt
 

dale_coop

Moderator
Staff member
The script looks correct...
Because it's a tile script, maybe your issue is that another object is colliding with this tile? Like a monster or a projectile... so the script is executed, so your player is losing a life and respawn again.

You could easily check that adding, at the beginning of your script:
Code:
	;; check to see if object colliding is a player.
	CPX player1_object
	BNE +skipHurt

Also... another small note (for optimisation), your script looks very like the handle player hurt script, so maybe you could just use:
Code:
	;; check to see if object colliding is a player.
	CPX player1_object
	BNE dontDoTilePlayerHurt
	
	;; call the handle player hurt code:
	JSR doHandleHurtPlayer
	
dontDoTilePlayerHurt:
 
Top Bottom