Death animation, checkpoints and Game Over screen
I'll explain a simple way of implementing this.
Context:
Your player is hurt and has no health left, instead of restarting the screen, we'll display his death animation. And if he still has lives, we'll send him back to the last checkpoint (if there is no checkpoint, he'll be respawned at the beginning of the game). If there are no lives left, we'll go to a dedicated Game Over screen.
Note:
I'm going to use the MetroVania module here (because it's the most widely used), but this tutorial should work with any module.
0) BACKUP YOUR FILES!
First thing first, make a backup of your NESmaker folder (copy/paste or right clic, send to Compress Zip Folder). Like that if anything goes wrong you can restaure your NESmaker files.
1) DEATH ANIMATION
Edit the Player object, and make any "death" animation for it:
For that tutorial, I will just make a 2 frames blinking Player ("death right" and "death "left" animations).
Then, in the Object Detail, assigned those death animations to a new "Death" animation type:
Now, we'll use the ACTION STEP 6 as the Player's "Death" state.
Select the Action Step 6, set the "Death" animation type, an animation speed, also set the "ignore gravity" flag and the EndAction to "GoToContinue" with a timer value of "4" (use any value you want here, it will be the duration of the death animation):
The "GoToContinue" will warp the Player to the last checkpoint.
2) CHECKPOINT TILE
Open the "Project Settings > Project Labels", and select a tile type that is not used and rename it as "Checkpoint".
For exemple here, I will rename the "Tile 13" to "Checkpoint":
Now in the "Project Settings > Script Settings", under "TileTypes", select the "Tile 13" element (because I chose to use the "tile 13" as my checkpoint just before).
Then, on the right side panel, navigate into the "BASE_4_5\Game\MOD_PlatformerBase\Tiles" folder and double-click on the "checkpoint_CheckpointBase.asm" to assign that script to the "Tile 13" element you have selected:
The checkpoint tiles should now work at this point. You can place checkpoint tiles at the beginning of each level of your game (at the spawn/warp in position).
Important note aout checkpoint tiles: if you place a checkpoint tile somewhere in a scrolling level (not on the first screen of the scrolling level), you need to set the Screen Infos exactly identical as the first screen of that scrolling level. Because when your player will respawn on that Checkpoint, that screen will become the first screen (loaded) of the scrolling section.
3) HANDLE PLAYER DEATH
We need to make sure that when the player dies, it plays the death animation (action step 6) and not just restart the screen (like it does currently).
In the "Project Settings > Script Settings" dialog, under Common, edit the "Handle Hurt Player" script (hurtPlayer_MetroidVania.asm):
Around the beginning of the script, find the:
Replace the "07" by a "06", like this:
Now, from line 32, you should see this:
Replace those lines with:
Your code should now look like:
Finally, search for the "+playerHealthIsZero" (around line 88)...
and comment out (or remove all the code) between "+playerHealthIsZero" and "+skipHurt", like that:
I'll explain a simple way of implementing this.
Context:
Your player is hurt and has no health left, instead of restarting the screen, we'll display his death animation. And if he still has lives, we'll send him back to the last checkpoint (if there is no checkpoint, he'll be respawned at the beginning of the game). If there are no lives left, we'll go to a dedicated Game Over screen.
Note:
I'm going to use the MetroVania module here (because it's the most widely used), but this tutorial should work with any module.
0) BACKUP YOUR FILES!
First thing first, make a backup of your NESmaker folder (copy/paste or right clic, send to Compress Zip Folder). Like that if anything goes wrong you can restaure your NESmaker files.
1) DEATH ANIMATION
Edit the Player object, and make any "death" animation for it:
For that tutorial, I will just make a 2 frames blinking Player ("death right" and "death "left" animations).
Then, in the Object Detail, assigned those death animations to a new "Death" animation type:
Now, we'll use the ACTION STEP 6 as the Player's "Death" state.
Select the Action Step 6, set the "Death" animation type, an animation speed, also set the "ignore gravity" flag and the EndAction to "GoToContinue" with a timer value of "4" (use any value you want here, it will be the duration of the death animation):
The "GoToContinue" will warp the Player to the last checkpoint.
2) CHECKPOINT TILE
Open the "Project Settings > Project Labels", and select a tile type that is not used and rename it as "Checkpoint".
For exemple here, I will rename the "Tile 13" to "Checkpoint":
Now in the "Project Settings > Script Settings", under "TileTypes", select the "Tile 13" element (because I chose to use the "tile 13" as my checkpoint just before).
Then, on the right side panel, navigate into the "BASE_4_5\Game\MOD_PlatformerBase\Tiles" folder and double-click on the "checkpoint_CheckpointBase.asm" to assign that script to the "Tile 13" element you have selected:
The checkpoint tiles should now work at this point. You can place checkpoint tiles at the beginning of each level of your game (at the spawn/warp in position).
Important note aout checkpoint tiles: if you place a checkpoint tile somewhere in a scrolling level (not on the first screen of the scrolling level), you need to set the Screen Infos exactly identical as the first screen of that scrolling level. Because when your player will respawn on that Checkpoint, that screen will become the first screen (loaded) of the scrolling section.
3) HANDLE PLAYER DEATH
We need to make sure that when the player dies, it plays the death animation (action step 6) and not just restart the screen (like it does currently).
In the "Project Settings > Script Settings" dialog, under Common, edit the "Handle Hurt Player" script (hurtPlayer_MetroidVania.asm):
Around the beginning of the script, find the:
Code:
GetActionStep temp
CMP #$07
BNE +canHurtPlayer
JMP +skipHurt
+canHurtPlayer
Now, from line 32, you should see this:
Code:
+healthBelowZero
JMP +playerHealthIsZero
+notDeadYet
ChangeActionStep player1_object, #$07
Replace those lines with:
Code:
+healthBelowZero:
;; player is dead, we play the death state:
ChangeActionStep player1_object, #$06
;; stop the scrolling :
LDA scrollByte
AND #%00111110
ORA #%00000010
STA scrollByte
;; and disables the inputs:
LDA #$FF
STA gameState
JMP +continue
+notDeadYet:
;; player is hurt, we play the hurt state:
ChangeActionStep player1_object, #$07
+continue:
Finally, search for the "+playerHealthIsZero" (around line 88)...
and comment out (or remove all the code) between "+playerHealthIsZero" and "+skipHurt", like that:
Last edited: