Main      Site Guide    
Smash Tutorial

Program Flow


Each move made in a Smash-based game causes a number of different snippets of code to execute. When programming a game, it's important to understand the order in which things occur, lest you make false assumptions about what happens when.

Sequence of Events That Occurs When a New Player Starts a Game

When a new player starts a game, the following steps are taken:

  1. The current move number is set to 0.
  2. If a copts.sma file exists, it is executed.
  3. The start.sma, which must exist, is executed.
  4. If a repeatpre.sma file exists, it is executed.
  5. The code for the starting location (as specified by a g command in the start.sma file) is executed.
  6. If a repeatpost.sma file exists, it is executed.

Sequence of Events That Occurs After the Player Makes Each Move

When the player selects a move to make in the game, the following steps are taken:

  1. The current move number is incremented by 1.
  2. Any and all timers set to values less than or equal to 0 are removed.
  3. All remaining timers are advanced by 1.
  4. The code for the user's selected action is executed.
  5. If a repeatpre.sma file exists, it is executed.
  6. If a g command was encountered in any of the above steps, the location change takes effect.
  7. The code for the current location (whether it changed or not in the previous step) is executed.
  8. If a repeatpost.sma file exists, it is executed.