How to add a "CheckPoint" type tile [NESMaker 4.0.6]

dale_coop

Moderator
Staff member
The checkpoint type tile manages to, if activated, to save the player progression until he looses all his lives. To activate a checkpoint the checkpoint tile, just walk on it.
Available in the beta, the checkpoint type tile is not in the adventure module... So this is how to bring back this functionality:

First, we need to add PlayerLives to the game. Because user variables are not yet implemented in the tool (except the hud ones, but too few variables there to be wasted), we need to declare the variable in the "GameEngineData\Routines\Variables\SystemVariables.asm" script, add this line at the end:
Code:
	playerLives     .dsb 1  ;; player lives

Then, open the "GameEngineData\Routines\InitializationScripts\initLoads.asm" script to set the initial value of your player lives:
Code:
	;;; delete me
	
	;;; SET UP INITIAL VARIABLE VALUE HERE:
	LDA #$03       ;; <<-- 3 LIVES
	STA playerLives  ;; player lives

And modify the "GameEngineData\Routines\UserScripts\AdventureGame_Base\HurtWinLoseDeath\Adventure_PlayerLoseLife.asm" script:
Code:
;;	JMP RESET
;; loose player lives
	LDA playerLives
	SEC
	SBC #$01
	BEQ noMoreLives
	STA playerLives
	
	LDA #STATE_START_GAME
	STA change_state
	
	JMP doneWithLoseLife
noMoreLives:
	JMP RESET
doneWithLoseLife:

Now add the following "Checkpoint.asm" script in the "GameEngineData\Routines\UserScripts\AdventureGame_Base\TileScripts" folder:
Code:
;; checkpoint
	
	LDA Object_type,x
	BNE nevermindSettingContinue
	LDA currentScreen
	STA continueScreen
	LDA Object_x_hi,x
	STA continuePositionX
	LDA Object_y_hi,x
	STA continuePositionY
	
	;;PlaySound #sfx_pick
	
nevermindSettingContinue:

Lastly, in the "Project Settings > Project Labels", rename for exemple the unused Tile Types "Tile 09" to "9 - CheckPoint", then in "Project Settings > Scripts Settings" assign the "Checkpoint.asm" script to "Tile Collision 09".

Voilà, now you can make Checkpoint type tiles! When the player is dead, he starts again from that checkpoint (until he looses his 3 lives)
 

WolfMerrik

New member
Very nice! This is definitely something I was thinking about down the road.
I was assuming that likely in the platformer tutorial, this would be something they may talk about, or even have scripts to implement. But, as always, you already came up with a clever and well-explained way! I am very excited to see what they have in store for that tutorial actually! (Crossing fingers for some rudimentary h-scrolling)

Seriously, man, I have more posts of yours bookmarked for NESMaker Development than official tutorials! Don't stop the great stuff!
 

dale_coop

Moderator
Staff member
Thank you WolfMerrik. NESMaker is my ASM learning tool (Like those kids program to learn how to code).
I think they will bring back the checkpoint tomorrow, with the Platform module.
 

WolfMerrik

New member
It has definitely taught to look at, and get a basic understanding of ASM. As far as actually writing anything in ASM code for myself, it is mostly just guessing, compiling, praying, adjusting. But that is a start!
 

Mihoshi20

Member
I made all the required changes, unfortunately the player never is placed at the checkpoint. After losing all health the game simply softlocks and must be reset.
 

dale_coop

Moderator
Staff member
Hmmm strange, I might forgot something?

You did assign in "Project Settings > Scripts Settings" the "Checkpoint.asm" script to "Tile Collision 09" (or whatever used)?
You did initialized your lives LDA“$03, in the "initLoads.asm"?
I will try again... (if joe didn't already add Checkpoints in the new module today).
 

dale_coop

Moderator
Staff member
Did you set your player's death animation? (as shown by Joe in the tutorial?)
In the Adventure Module, the game object "Effect 0" is the player death effect. You need to set up (Action "0" --> "end of animation" -> "restart the game").
 

Mihoshi20

Member
dale_coop said:
Did you set your player's death animation? (as shown by Joe in the tutorial?)
In the Adventure Module, the game object "Effect 0" is the player death effect. You need to set up (Action "0" --> "end of animation" -> "restart the game").

Yeah, death animation is set and LDA #$03 is set. Just to make sure I set the hud to show lives and when losing all health, the lives are also not subtracted... that or the hud isn't updating to reflect the update as the game simple softlocks so it's difficult to tell.
 

dale_coop

Moderator
Staff member
1/ Check you made the modifications in the "GameEngineData\Routines\UserScripts\AdventureGame_Base\HurtWinLoseDeath\Adventure_PlayerLoseLife.asm" and THAT particular script is asssigned to "Handle Lose Life" in 'Project settings > Scripts settings"?
2/ And still in "Project settings > Scripts" check also that the "checkpoint.asm" script is assigned to "Tile Collision 09" (or another one).
3/ Than check your Asset (its collision tile type)... and put this CheckPt asset again on your screen.

I tested again yesterday with an freshly unzipped NESMaker 4.0.6 folder and it worked.
 

Mihoshi20

Member
dale_coop said:
1/ Check you made the modifications in the "GameEngineData\Routines\UserScripts\AdventureGame_Base\HurtWinLoseDeath\Adventure_PlayerLoseLife.asm" and THAT particular script is asssigned to "Handle Lose Life" in 'Project settings > Scripts settings"?
2/ And still in "Project settings > Scripts" check also that the "checkpoint.asm" script is assigned to "Tile Collision 09" (or another one).
3/ Than check your Asset (its collision tile type)... and put this CheckPt asset again on your screen.

I tested again yesterday with an freshly unzipped NESMaker 4.0.6 folder and it worked.

I finally caught it. Went through and triple checked everything again step by step and that's when I caught it. End animation on effect 0 was set to 'destroy me' somehow instead of restart game. While I was reading this post something on the quote in my reply above it caught my eye. I went back to check the end animation again and that's when I found it. It's working perfectly now, respawn is working and lives counter is working. So happy to have this working again. You're always such a massive help and very glad to have you with us. :D
 

Mihoshi20

Member
dale_coop said:
Glad you found! :)
Yeah, it's very useful, that checkpoint ^_^ ah ah

Yes indeeds as I now have everything needed to get down to the hard work of actually making my game. LOL! I'll be sure to credit your contribution once it's done as you have been a MASSIVE help as always. Can't wait to see more of your game too and play it.
 

JeffPack

New member
Is this still the preferred method in 4.0.11?
I set this up and it works great when dying on most screens. On some screens however when I die I end up spawning in the top left of the starting screen which transitions me to a different screen and usually just starts glitching. In some cases it will even start the game just fine but then when I go to leave the screen it starts doing the same thing. Here's all of my relevant scripts.

Adventure_PlayerLoseLife.asm (using a HUD variable for myLives)
Code:
;;	JMP RESET
;; loose player lives
	LDA myLives
	CLC
	CMP #$00
	BEQ noMoreLives
	SEC 
	SBC #$01
	STA myLives
	
	LDA #$04
	STA myHealth
	
	LDA #STATE_START_GAME
	STA change_state
	
	JMP doneWithLoseLife
noMoreLives:
	JMP RESET
doneWithLoseLife:

setContinue.asm (This is assigned to tile 08... see pic below)
Code:
	CPX player1_object
	BNE nevermindSettingContinue
	JSR GetTileAtPosition
	LDA collisionTable,y
	BEQ nevermindSettingContinue ;; already tripped this, other points don't need to check.
	LDA currentScreen
	STA continueScreen
	LDA Object_x_hi,x
	STA continuePositionX
	LDA Object_y_hi,x
	STA continuePositionY
	ChangeTileAtCollision #$00, underStomp

nevermindSettingContinue:

Capture.PNG

Again... this is working intermittently ... in fact the checkpoint itself always works. I have a feeling it has something to do with the change state?
 

dale_coop

Moderator
Staff member
Or maybe you put your checkpoint too close from the edge ? 1st row or col is something you need to avoid.
 

JeffPack

New member
dale_coop said:
Or maybe you put your checkpoint too close from the edge ? 1st row or col is something you need to avoid.

Good to know thanks! So this happens before I've hit a checkpoint at all. And if I bypass the lose life logic and do a simple reset I have no problems.

I should also say that this happens when I reduce the lose life code to the following

Code:
	LDA #STATE_START_GAME
	STA change_state
	
	JMP doneWithLoseLife
noMoreLives:
	JMP RESET
doneWithLoseLife:

Another thing I don't understand is why in the platform module code the lose life function just has a simple

Code:
JMP RESET

and it somehow mysteriously works... ?
 

JeffPack

New member
Figured it out. A bug in the engine code causes the change state code to use the warp in location from the screen the checkpoint is on after you have used a warp.
http://nesmakers.com/viewtopic.php?f=23&t=962
 

LCM Games

New member
You're a life saver, Dale... I've been trying to figure out how to activate a checkpoint in the adventure module for what feels like forever!
 

dale_coop

Moderator
Staff member
Ah ah you’re welcome...
It’s very fun to try to add the things that used to work, or should work, or would be useful. A lot of things I don’t understand well yet. But practicing and dggin’ makes me learn a lot.
I think it’s the new version coming this week, we will have a ton of new things to toy with.
 
hey dale ive been experiencing a weird bug since i added these checkpoints to version 4.0.11
when i use a projectile in the adventure module to destroy a breakable block, the block is only destroyed if i hit it from the top or the right side? im digging through the breakable block asm but cant find anything out of the ordinary. could the checkpoint code affect this in any way or no?
 
Top Bottom