Lives, Hurt and Monster Death


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).

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.


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.

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.

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.

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.

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:

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)