Game Over Special Screen

dale_coop

Moderator
Staff member
baardbi said:
Amazing! :) :) It works perfectly. Thank you so much for all your help Dale. I really appreciate it. :)

Glad it worked.
My pleasure, baardbi ;)
And feel free to share your project in the WIP section ;)
 

TolerantX

Active member
I tried this in NESmaker 4.5.2. but had some problems when it triggered.... it basically didn't trigger.
the player keeps losing lives while makes some weird artifacts in the HUD but never warps.


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 myLivesNotZero
	;JMP RESET ;; game over.
	;;;; also could warp to game over screen here instead. ;;
	WarpToScreen #$00, #$02, #$01  ;;test numbers to try to warp to screen 2 or 3 i dont care as long as it warps;;
	;; arg0 = warp to map.  0= map1.  1= map2.
	;; arg1 = screen to warp to.
	;; arg2 = screen transition type - most likely use 1 here.
		;; 1 = warp, where it observes the warp in position for the player.
	
myLivesNotZero:

	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
Don't forget the
Code:
	JMP +skipHurt
After your
Code:
	WarpToScreen #$00, #$02, #$01  ;;test numbers to try to warp to screen 2 or 3 i dont care as long as it warps;;
line.

Also, make your your warp screen value is correct... for example, if you use a "GAME_OVER_SCREEN" to identify that screen (in the overworld), your warp line should be
Code:
	WarpToScreen #$00, #GAME_OVER_SCREEN, #$01
 

TolerantX

Active member
Thank you! This helped a lot. Okay NESmakers! so here's how it works... the code itself has a lot commented to explain things out simply.
you don't need to create any variable because you need to know where you're setting your warp and hex convert or just use the coordinates I provided. (*If you are okay with using 8x8 on a Game Over Screen AND your last screen on the UNDERWORLD)

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 myLivesNotZero
	;JMP RESET ;; game over.
	;;;; also could warp to game over screen here instead. ;;
	
	WarpToScreen #$01, #$E7, #$01  ;;This is warp to UNDERWORLD, LAST SCREEN this is for me because 8x8 , #$01 is normal warp;;
	;; arg0 = warp to map.  0= map1.  1= map2.
	;; arg1 = screen to warp to. use mouse to find coordinates = #$yx use hex convertor. 
	;; arg2 = screen transition type - most likely use 1 here.
		;; 1 = warp, where it observes the warp in position for the player.
	;;Don't Forget to set WARP IN COORDINATES ON YOUR MAP!;;

	JMP +skipHurt

myLivesNotZero:

	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

works for you? Please make sure to read the commented out lines for more help.
Cool? Alright moving on to another cool thing you can do with this!!!!
See how you just wrote a script that when you die warps you?
this is the playerhurtreset tile made to actually account for all lives too!

Code:
	;;; Reset with Lives that uses can hurt player type script.
	;; check to see if object colliding is a player.
	;; if not, do not reset.
	CPX player1_object
	BNE dontDoTileReset
	;;JMP RESET
	JSR +canHurtPlayer  ;;; this is safer than just using a JMP command here ;;
dontDoTileReset:

Now for OTHER games you may want to use myHealth and take damage or die instantly or you may want to have it play a death animation then after that warp you.... that would be different scripts, but related to this. Those can be written for those games at a later time. This is a simple solution for most people to use.
 

Saulus_Lira

Member
I loved the tutorial, and quickly put it in my game.
I'm using it in version 4.1.5 (I know it's outdated, but I'm working on another project in the new version). Well, let's go.
I'm having problems with warp to game over screen. when I go to the screen it just flashes and then I enter another screen (which is not the GameOverScreen).
The other problem (I'm hitchhiking on this post) is that when trying to hide my HUD (Screen Info settings) my game crashes.
I am very new to these things, and it would take time to search for it myself, but this forum is special and has helped me a lot to accomplish some good things, mainly Dale_Coop, which for me is a kind of "master of the magicians" of the forum.
I thank you for your help.
 

dale_coop

Moderator
Staff member
Your game crashes because by hiding your hud, your sprite 0 right not be able to have a collision with a non transparent pixel.

You can fix that issue... Modify the script assigned to the "Handle Sprite Pre-Draw" element in your "Project Settings > Script Settings":
2020-07-05-20-25-08-Project-Settings.png


And, before the line (around line 38):
Code:
;;;; DRAW SPRITE ZERO FOR SPRITE ZERO HIT

Add this code:
Code:
	;; if "Hide Hud" screen flag is set, skip the sprite drawing:
	LDA screenFlags
	AND #%00000001
	BNE +

Like this:
2020-07-05-20-27-31-Z-NESMaker-4-1-5-demos-Game-Engine-Data-Routines-Basic-Module-Scripts-Main-Scrip.png


Voilà, now, it should not freeze your game anymore.
 

Jonny

Well-known member
chronicleroflegends said:
Thanks, I did it and even though its simple, I think it looks really good.


Do you have a pic of what you ended up with? I went though a similar process for my start screen. I started with something far too complex, spent ages with it, then completely redid it.

I ended up with only these tiles... (and some existing monster tiles). I've tried to make it so I can re-use the tileset to write other words, like game over for example.


BckCHR_14.gif


BckSSChr29.gif


start.gif
 

Saulus_Lira

Member
dale_coop said:
Your game crashes because by hiding your hud, your sprite 0 right not be able to have a collision with a non transparent pixel.

You can fix that issue... Modify the script assigned to the "Handle Sprite Pre-Draw" element in your "Project Settings > Script Settings":
2020-07-05-20-25-08-Project-Settings.png


And, before the line (around line 38):
Code:
;;;; DRAW SPRITE ZERO FOR SPRITE ZERO HIT

Add this code:
Code:
	;; if "Hide Hud" screen flag is set, skip the sprite drawing:
	LDA screenFlags
	AND #%00000001
	BNE +

Like this:
2020-07-05-20-27-31-Z-NESMaker-4-1-5-demos-Game-Engine-Data-Routines-Basic-Module-Scripts-Main-Scrip.png


Voilà, now, it should not freeze your game anymore.


Thanks again. May the universe conspire in your favor !! ;)
 
Jonny said:
Do you have a pic of what you ended up with? I went though a similar process for my start screen. I started with something far too complex, spent ages with it, then completely redid it.

I ended up with only these tiles... (and some existing monster tiles). I've tried to make it so I can re-use the tileset to write other words, like game over for example.

My game over screen is pretty simple. It just uses a sprite for the dead player, and has a tileset for the game over text.
 

Attachments

  • Annotation 2020-07-19 201809.png
    Annotation 2020-07-19 201809.png
    12.6 KB · Views: 966

PasseGaming

Active member
Okay, I have a question. Does this work for 4.5.6? An if so where does this code go? or do I use the code dale gave at the beginning of the thread and add this stuff? Tried to follow along but I keep getting confused.

TolerantX said:
Thank you! This helped a lot. Okay NESmakers! so here's how it works... the code itself has a lot commented to explain things out simply.
you don't need to create any variable because you need to know where you're setting your warp and hex convert or just use the coordinates I provided. (*If you are okay with using 8x8 on a Game Over Screen AND your last screen on the UNDERWORLD)

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 myLivesNotZero
	;JMP RESET ;; game over.
	;;;; also could warp to game over screen here instead. ;;
	
	WarpToScreen #$01, #$E7, #$01  ;;This is warp to UNDERWORLD, LAST SCREEN this is for me because 8x8 , #$01 is normal warp;;
	;; arg0 = warp to map.  0= map1.  1= map2.
	;; arg1 = screen to warp to. use mouse to find coordinates = #$yx use hex convertor. 
	;; arg2 = screen transition type - most likely use 1 here.
		;; 1 = warp, where it observes the warp in position for the player.
	;;Don't Forget to set WARP IN COORDINATES ON YOUR MAP!;;

	JMP +skipHurt

myLivesNotZero:

	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

works for you? Please make sure to read the commented out lines for more help.
Cool? Alright moving on to another cool thing you can do with this!!!!
See how you just wrote a script that when you die warps you?
this is the playerhurtreset tile made to actually account for all lives too!

Code:
	;;; Reset with Lives that uses can hurt player type script.
	;; check to see if object colliding is a player.
	;; if not, do not reset.
	CPX player1_object
	BNE dontDoTileReset
	;;JMP RESET
	JSR +canHurtPlayer  ;;; this is safer than just using a JMP command here ;;
dontDoTileReset:

Now for OTHER games you may want to use myHealth and take damage or die instantly or you may want to have it play a death animation then after that warp you.... that would be different scripts, but related to this. Those can be written for those games at a later time. This is a simple solution for most people to use.
 

mouse spirit

Well-known member
Im guessing this is specifically made for 4.1 code. And they look like playerhurt scripts so somewhere like handleplayerhurt.asm.
 

PasseGaming

Active member
It looked like at one point they modified the script for 4.5.6 but I can't be sure. Sort of confusing following along with this one.
 

mouse spirit

Well-known member
I think in 4.5 you can set up a special screen. Make a game state for it called gameover state.
make it so the only input for that gamestate warps you to where you want to go and resets life and lives.
In a nutshell.
 

PasseGaming

Active member
mouse spirit said:
make it so the only input for that gamestate warps you to where you want to go and resets life and lives.
In a nutshell.

^thats what I am hung up on. The input script that Dale offered doesn't appear to work with the 4.5 script tolerantx gave us. I got the below error code.

those lines of code are 2) LDA currentScreen 4) CMP #GAME_OVER_SCREEN

scripterror.png
 

mouse spirit

Well-known member
i think those lines reference variables. so they just need renamed. can you share the script you have that has the error?
 

PasseGaming

Active member
It's the exact same script Dale shared on the first page. Didn't see any other code for the inputs, so I assumed this would do it.

Code:
    ;; if on the GAME OVER screen
    LDA currentScreen
    CLC
    CMP #GAME_OVER_SCREEN
    BNE +
    JMP RESET
+
	RTS
 
Top Bottom