Projectiles


What Modules Allows Shooting?
Player Weapon Objects
Fixing a Little Bug

NESmaker includes some input scripts that will make the player shoot a projectile. By default there are no such scripts for monsters to shoot. Custom scripts like that can of course be made (like we see in the picture above), but it will require programming in 6502 Assembly Language. In this section we will only look at the included scripts in NESmaker. The NESmaker forum has a few posts that talk about monster projectiles.

What Modules Allows Shooting?

There are three modules in NESmaker that supply a shoot projectile input script. However, it’s important to understand that it doesn’t mean we can’t shoot in other modules, but we need to add the shoot input script from another module. The three modules that include shooting by default are:

  • MetroidVania: shootProjectile_scrolling_SuperAmmo.asm
  • LR Platformer: shootProjectile_scrolling.asm
  • Shooter: shootProjectile_timer.asm

The input scripts mentioned above can be found in the Inputs folder of the respective modules. The shoot input script needs to be added together with all other input scripts, and it also requires you assign it to a specific button. See the section for setting up input scripts for more details.

Some shoot projectile input scripts are set up to use ammo. If we look at the MetroVania module we see that it uses ammo, and the variable myAmmo is set up with a start value of 5. That means (by default) you will start the game by firing the so-called super shot five times before switching to the normal weapon. Personally that feels strange to me, so I just start by setting the myAmmo variable to 0 in Project Settings – User Variables.

Player Weapon Objects

The player projectile needs to be an object. Game Object 1 is set up as the player projectile object in the shoot input scripts. If you use the MetroVania module, then Game Object 2 is set up as the super projectile. This really doesn’t have any real meaning. By default you can’t make one projectile stronger than another. It was probably done that way in the input scripts as an example to show how we can have different projectiles.

Setting up a player projectile object is easy. Just follow these simple steps. Remember to use Game Object 1 as the player projectile.

1. Select a graphic and a subpalette for the projectile. Then click Object Details.


2. Go to the Details tab and make sure player weapon is checked. It’s usually a good idea to set solid reaction and edge reaction to Destroy Me. Set speed and acceleration. You might need to experiment with those values.


3. Check the Ignore Gravity checkbox, unless of course you want the projectile to roll along the floor.


4. Make sure the player projectile has a bounding box.


Close the Object Details window and you’re done.

Fixing a Little Bug

There’s a tiny bug in the NESmaker code that destroys the monster object when the player weapon collides with it. If you want a super basic game without any score, random monster drops or monster death animation (explosion etc. ), then you can skip this step. However, I strongly recommend you do this step as it is very quick and simple to do.

1. Open Project Settings by clicking the little cogwheel icon on the toolbar.

2. Go to the Script Settings tab and scroll down till you see the folder icon called SubRoutines. Find and select Handle Object Collisions. Then click the Edit button on the top.

This will open the script file in your code editor, like for example Notepad++.

3. Scroll down to line 117. Put a semicolon in front of the macro DestroyObject. Save the file and you’re done.

Now the handle monster hurt code will be run, and you can add things like monster death explosions or random drops (by modifying the Assembly code) when the monster dies.