Metroid Learning – The structure of the game script

The game.lua script serves the purpose of keeping track of every piece of data in the game that the player can directly affect or interact with. Metaphorically, it can be seen as the screen that the AI looks into as well as the controller that the AI is holding. The next step of this project is to adapt this script from Super Mario World logic to Super Metroid logic – which takes more effort than it seems at first sight.

In this blog, I will explain go over the essentials of the game script (by example of MarI/O).

The script is structured into three sections: player datagraphic data and input data.

 

Player data

Figure 1 – Player data

Player data describes everything that is related to the player. One easily understandable example for this kind of data is the current amount of lives. The script provides both the means to read as well as to change the current amount of lives, as shown in Figure 1.

In Super Mario World, the player data includes…

  • Mario’s position on the screen
  • the amount of collected coins
  • the current points
  • the current lives
  • active power-ups
  • information whether the player was hit recently.
  • a timer that keeps track of when the player was hit.

 

Graphic data

Figure 2 – Graphic data

Graphic data is quite straightforward. It describes everything that is shown on the screen. In the case of SNES games, this data includes sprites and tiles. There might be more to consider when coding AI for newer console games.

While sprites are basically images, tiles work as references to sprites, according to GameDev StackExchange.

The game script loads graphics dynamically. For example, It only considers tiles in the direct vicinity of the player and loads each one individually by calculating its pointer table address, as shown in Figure 2.

 

Input data

Figure 3 – Input data

Input data describes everything that may be used to control the game. In a SNES game, there can only be one possible source of input.

The SNES controller provides 10 buttons in total, as shown in Figure 4. In most cases, two of those buttons (the ‚Start‘ and ‚Select‘ button in the center) are rarely used and will be neglected in this project.

Input data sets up the controller (or Joypad) by loading the buttons that are set in the config file (which will be changed last), as shown in Figure 3. Once the setup is finished, the script keeps track of given inputs and adjusts the graphics in the near vicinity of the player. This process, however, is very complicated and therefore a story for another day.

 

Figure 4 – SNES controller
Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

13 + zwölf =