Input Scripts
Setting Up Inputs
Common Inputs for all Modules
Inputs in NESmaker means input from the gamepad controller. We have 4 buttons and 8 directions on the D-Pad (directional pad). Since you’re reading this, this is probably obvious to you, but for the sake of completion here are the different inputs:
D-Pad:
- Up
- Down
- Left
- Right
- Up Left
- Up Right
- Down Left
- Down Right
Buttons:
- Select
- Start
- B Button
- A Button
What might be not quite as obvious is that each of these inputs from the gamepad controller can be in one of three states. Let’s take a quick look at the different states:
- Press – Pressing down a button
- Hold – Holding the button pressed
- Release – Releasing the button
We use a combination of these things when setting up inputs in NESmaker. So we can for example set up what we want to happen when we hold down Right on the D-Pad, or what happens when we press the A button. Maybe we want an action to trigger when we release the A button as well.
Input Scripts
Like with everything else in the game, the inputs are also tied to Assembly Language files. These are called Input Scripts in NESmaker. There are several input scripts bundled with NESmaker, so you don’t have to make your own. However, there are some posts on the NESmaker forum that provides custom input scripts.
Another thing we need to be aware of is that different modules in NESmaker have different input scripts. If we think about it, we can see that it makes sense. The Adventure module, which is a top-down game where you can walk in 4 or 8 different directions, needs different inputs than the LR Platformer where you can only walk left or right. In platform modules we also need scripts to make the player jump. The default supplied input scripts can be a little confusing at first because you sometimes need to mix input scripts from different modules. Let’s take a look at the input script folders.
In the folder …\NESmaker_4_5_x\GameEngineData\Routines\BASE_4_5\Game you can see the different folders for all modules. Here we also see a folder called inputScripts. This is the main input scripts folder which includes basic scripts like moveLeft.asm, moveRight.asm and stopMoving.asm. These are examples of scripts that will be used by all modules, but you sometimes need to mix them together with module specific scripts. You can find the module specific scripts in the different folders together with the inputScripts folder. For example the inputs for the Adventure module are here:
…\GameEngineData\Routines\BASE_4_5\Game\MOD_AdventureBase\Inputs
Adding Input Scripts
By default (when you start a new project) there are no input scripts added to your game. So we need to add the scripts we need. This is done in the Context Menu on the left, under Scripts – Input Scripts.
In this example we will add input scripts for the Maze module. The way we add scripts is by making sure Input Scripts is selected (like in the picture above). Then we need to double click on <DIR> BASE_4_5 on the right. Then we double click <DIR> Game. We can now see all the folders for the different modules, but in this case we will only add scripts from the main input scripts folder. Double click <DIR> inputScripts. Here are all the input scripts that are available in this folder. We double click on the scripts we want to add them. You will see that they disappear from the list, but they are added under Scripts – Input Scripts in the Context Menu on the left. Double click on the script called moveDown.asm. You should see it disappear from this list, and it will be visible under the Input Scripts folder icon on the left. Do the same for the following scripts:
By clicking on an input script we can view or modify the code. If you modify it, then don’t forget to click the Save button. Any changes you make to the script will go away if you click another input script (or another element in the Context Menu on the left in NESmaker). If you have a code editor that can handle Assembly files (.asm) installed on your PC, then you can double click the input script and it will be opened in your default code editor.
Setting Up Inputs
We have now added all the scripts we need for the Maze module. However, the scripts are only added to our project. They still don’t do anything. So we need to tell NESmaker how we want to trigger the different scripts. This is done by using the Input Editor which we can find in the Context Menu on the left. Click Input Editor. The section on the right of NESmaker will change and you should see a picture of an NES controller. Now we need to make some choices from the different drop-down menus at the top. Let’s take a quick look at the different drop-down menus.
Game State: Screens in NESmaker can be set up with different game states. This is covered in another section. To set up our inputs to apply to normal gameplay we need to select Main Game from this list.
Target: This is a list of all the Game Objects in our game (only Game Objects, not Monster Objects). We can choose what object we want to control. You should almost always choose Player from this list. Although you can choose any game object, you might run into issues if you choose another object since the NESmaker code is set up to handle the first game object as the player object. So until you are very comfortable with how NESmaker works, I recommend only selecting Player from this list.
Script To Run: This is a list of all the input scripts we added to Scripts – Input Scripts. Choose whatever script you want to run according to the input you are currently setting up.
Controller 1: We can also change what gamepad controller we want this particular input to apply to by pressing this button. It’s usually best to leave this at the default (Controller 1), especially if you are making a 1 player game (which all NESmaker modules are made for).
Choosing the correct input on the controller is very user friendly. You simply click on the button or direction on the D-Pad you want this action to apply to, and then choose what button state should trigger this action (press, hold or release). Just click on the button that says Press if you want to change the state.
In this example we are choosing Hold Down on the D-Pad.
When you are done choosing all the different options for this input, you just click the button labeled Add Script. If you added a script by mistake, you can remove it by selecting it in the script list, then right click it and choose Remove.
Common Inputs for all Modules
Here are some examples on how to set up inputs for each module. Notice that most modules have a mix of inputs from different Input Script folders.
Click on the image to see a larger version.
Adventure
Arcade Platformer
Brawler
Shooter
LR Platformer
Maze
MetroVania