Player death doesn't work

baardbi

Well-known member
Help!

I screwed up big time (and no I didn't make a backup...) :oops:

I was trying to change something when my player loses a life, but it didn't work. So then I tried to change something else, and that made it worse. So then I paniced and tried several things, and now the game just freezes when my player loses a life. I just want to get back the basic functionality:

- Create player death object
- Subtract a life
- Start at the start screen

I didn't change the scripts very much in the first place, so if there is an easy way to get back to default that would probably work.

Here is my Project Settings and the code for HandlePlayerDeath and PlayerLoseLife:

PS! I learned my lesson. From now on I will make backup a part of my development routine... :oops: :lol:

Project Settings:

handleplayerdeath.png


HandlePlayerDeath.asm

Code:
	CPX player1_object
	BNE +
	JSR HandlePlayerDeath
	PlaySound #SND_HURT_PLAYER
+


PlayerLoseLife.asm

Code:
;;; do loss of life stuff here
	DEC myLives
	LDA myLives
	BNE gameNotOver
	;;do gameover stuff here.  Warp to screen?  Show animation?  Just restart?
	;JMP RESET
	LDA #GAME_OVER_SCREEN
	STA continueScreen
	
gameNotOver:
	;;;;;
	;;; do warp to continue screen stuff here.
	LDA #$00
	STA newGameState
	LDA continueMap
	CLC
	ADC #$01
	STA temp
	GoToScreen continueScreen, temp, #$04	
	LDA #$00
	STA playerToSpawn
	LDX player1_object
	DeactivateCurrentObject	
	LDA #$01
	STA loadObjectFlag

	;DeactivateCurrentObject
	StopSound
	
	;;;;;;;;;;;;;;;;;;;
	;LDX player1_object
	;LDA Object_x_hi,x
	;STA temp
	;LDA Object_y_hi,x
	;STA temp1
	;CreateObject temp, temp1, #$08, #$00, currentNametable
	;; need to do this redundantly, otherwise, the death object will be in same slot as player
	;PlaySound #SND_HURT_PLAYER
	;;;;;;;;;;;;;;;;;;;

	;PlaySound #$00, #$00
	LDA #$FF
	STA player1_object
	
	LDX tempx
	LDY tempy
 

WillElm

New member
I just checked my scripts. The first one is the same, the default PlayerLoseLife just does this:

Code:
	JMP RESET
 

baardbi

Well-known member
Thank you for checking, but it didn't help. Seems like I have some weird issue with a script file that doesn't show up in script settings. I will probably export all my graphics and assets and try to rebuild the game from scratch tomorrow. Thanks anyway :)
 

dale_coop

Moderator
Staff member
Check the "OBJ_PLAYER_DEATH" constant value (in your "Project Settings > User Constants", it defines which object to use. By default it should the object #8

Set the graphics / animations for that object. Set the Action Step 0 to do nothing... (just playing the animation). With a End Animation to "Restart Game" and don't forget the animation speed (if you prefer using End Action instead, set it to "Restart Game" and a Timer value).

It should work
 

dale_coop

Moderator
Staff member
The main errror in your project is, you assigned the script HandlePlayerDeath.asm to the "Handle Player Death" element in the "Project Settings > Script Settings". It's incorrect.
The "CreatePlayerDeathObject.asm" script should be assigned to the "Handle Player Death" element (it designate the script to be executed when the HandlePlayerDeath virtual routine is called).

For the PlayerLoseLife.asm script... if you follow the topic about GameOver screen, it should be correct.
 

baardbi

Well-known member
AMAZING!!! You fixed it. The CreatePlayerDeath setting was the problem. Thank you so much Dale! You are a wizard :) :) :)
 
Top Bottom