Main      Site Guide    
Smash Tutorial

Sample Adventure: The Trainer

The "coin.sma" File


This file handles the location where the player can find the coin. The logic is pretty simple: initially, the coin is hidden from view, but the player discovers it when he kicks at the leaves. At that point, the coin becomes available to pick up.

The variable "coin_visible" keeps track of whether or not the coin has been discovered yet. It is initially set to 0, which means that it is still there but hidden from view. When the player kicks at the leaves, "coin_visible" becomes 1, to indicate that the coin has been found and can be taken. After it is taken, "coin_visible" becomes 2. It is important that "coin_visible" does not get set back to 0 when the coin is taken; otherwise, the player could "find" it again after kicking at the leaves a second time. By setting "coin_visible" to 2, we know not to have the player find the coin a second time.

. You're in a secluded area some distance from the lake shore. Dead leaves are scattered throughout the area. c coin_visible = 1 , There is a coin on the ground here. ^ e Go east. g kobold * 1 Look around. p You see a bunch of dead leaves on the ground, roots exposed from erosion, and lots of gnats flying at your face. * 2 Kick at the leaves. c coin_visible p It's fun, isn't it? C p You found a coin hiding underneath a leaf! s coin_visible = 1 c coin_visible = 1 * 3 Take the coin. p Whatever you say. a coin s coin_visible = 2