![](https://i0.wp.com/board-b.com/wp-content/uploads/2024/06/Lives.png?resize=512%2C480&ssl=1)
Lives
Player Hurt
Monster Hurt
Making a Monster Death Explosion
Game Over
Lives
The first thing we need to understand when dealing with player lives in NESmaker is that not all modules use lives. Some modules are set up to only use health, and when the health is empty the game will restart or whatever is set up for that module (usually it will go to the latest checkpoint if that is set up). Let’s take a quick look at what modules use lives and what modules use health.
Health:
- Adventure
- Brawler
- MetroVania
Lives:
- Arcade Platformer
- Shooter
- LR Platformer
- Maze
The modules that use lives will have a User Variable called myLives. That will keep track of how many lives the player has at any given time. You can find the variable in Project Settings – User Variables. By default it will be set to 3 (lives).
![](https://i0.wp.com/board-b.com/wp-content/uploads/2024/06/myLives.png?resize=625%2C366&ssl=1)
To see or modify what happens when the player loses a life you must open the Handle Player Hurt script. That can be found in Project Settings – Script Settings under a folder icon called Common. The label for the script is Handle Player Hurt. Select it and click Edit. This script will be different for each module. So modules that don’t have lives will not include the myLives variable in the code. Look for the label in the script called +doHurtPlayer. Since modifying this file requires custom Assembly code and can be very different from game to game, we will not look at modifying the file here. I recommend asking for help on the NESmaker forum if you need to modify the player hurt script.
![](https://i0.wp.com/board-b.com/wp-content/uploads/2024/06/HandlePlayerHurt.png?resize=625%2C247&ssl=1)
Player Hurt
Like with player lives, player hurt is also different between modules. The main thing with player hurt is that the player has health and goes into a hurt state when he collides with a monster or a monster weapon. The default hurt state in NESmaker is Action Step 7. If you use a module that has health instead of lives you should set up Action Step 7 with a hurt graphic. You also need to set a timer for this state so that the player will go back to normal after a little while. In this example we use 3 for the Action Timer and GoToFirst for EndAction. It’s usually a good idea to have a hurt animation frame for this state as well.
![](https://i0.wp.com/board-b.com/wp-content/uploads/2024/06/PlayerHurtActionStep.png?resize=625%2C638&ssl=1)
To view or modify the player hurt script you must open the code file from Project Settings (see example above under Lives).
Monster Hurt
Monster hurt works very much the same way as the player hurt setup. The monster objects also use Action Step 7 for their hurt state, so you can set it up exactly like in the picture above. In order for the monsters to go into their hurt state we must fix a tiny bug in NESmaker. By default the monster object will disappear when we shoot it with a player weapon. You can find the fix for that here.
To view or modify the code for Monster Hurt you must open the hurt monster script. This is done from Project Settings – Script Settings.
![](https://i0.wp.com/board-b.com/wp-content/uploads/2024/06/MonsterHurt.png?resize=625%2C250&ssl=1)
Making a Monster Death Explosion
In order to do this it is important that you did the fix mentioned above. This doesn’t have to be an explosion, it could be whatever monster death animation you want. But in this example I will use an explosion.
![](https://i0.wp.com/board-b.com/wp-content/uploads/2024/06/MonsterExplosion.png?resize=625%2C388&ssl=1)
Start by drawing a monster death animation (for example an explosion) in the Pixel Editor. Make sure you draw it in the GameObjectTiles.bmp file. In this example I have chosen Game Object 8 to be the monster death animation object. I used 4 frames of animation for this, but you can choose the number of frames you want. Start by setting up the size of the object and the animation. Then open the Object Details window. Depending on whether you are using a game with gravity (platform game) or not, that checkbox will be different based on the module.
![](https://i0.wp.com/board-b.com/wp-content/uploads/2024/06/MonsterDeathExplosion.png?resize=625%2C332&ssl=1)
Set the values as shown in the window above. Then click close. Now you must open the Project Settings – Script Settings. Find Handle Monster Hurt under Common. Select it and click Edit. This example code is for the MetroVania module, so if you are using another module you might have to slightly modify the code. Before you make any changes to this file you should probably make a backup of it first, so in case something goes wrong you can always restore the original code. After making a backup of the code you can replace it with this:
TXA
STA temp
GetActionStep temp
CMP #$07 ;; we will use action step 7 for hurt.
BNE +dontSkipHurtingThisObject
JMP +doSkipHurtingThisObject ;; if he is hurt, he can't be hurt again.
+dontSkipHurtingThisObject:
ChangeActionStep temp, #$07
LDA #$80
STA Object_action_timer,x
DEC Object_health,x
LDA Object_health,x
BNE +doSkipHurtingThisObject
LDA Object_x_hi,x
STA tempA
LDA Object_y_hi,x
STA tempB
LDA Object_screen,x
STA tempC
DestroyObject
;;; Game Object 8 is the monster death animation (explosion)
CreateObjectOnScreen tempA, tempB, #8, #0, tempC
CountObjects #%00001000
BNE +notZeroCount
LDA scrollByte
ORA #%00000010
STA scrollByte
;;; if there are no more monsters left, we want to disable
;;; the edge check for scrolling.
LDA ScreenFlags00
AND #%11101111
STA ScreenFlags00
+notZeroCount
+doSkipHurtingThisObject
This modification will change the hurt monster code from just destroying the monster (just making it disappear) to creating the monster death animation object (explosion) at the exact position of the monster and destroying the monster object as well (like in the original code).
Game Over
Unfortunately there is no proper setup for Game Over by default in NESmaker. That means we have to program that for ourselves. This is usually done by modifying the player hurt script. There is a great tutorial on the NESmaker forum that shows how this can be done:
Player’s Death Animation, Checkpoints and Game Over screen (metroVania module)