5.1 A Simple Level

Here is a very simple level description that can also serve as a starting-point for new landscapes. (In fact, this is the first level in Enigma, so you can try it out right away.)

 1   create_world(20, 13) 
 2   draw_border("st-brownie")
 3   fill_floor("fl-hay", 0,0, level_width,level_height)
 4
 5   set_stone("st-fart", level_width-1,0, {name="fart"})
 6   set_stone("st-timer", 0,0, {action="trigger", target="fart",
 7             interval=10})
 8
 9   oxyd(3,3)
10   oxyd(level_width-4,level_height-4) 
11   oxyd(level_width-4, 3) 
12   oxyd(3,level_height-4) 
13   oxyd_shuffle() 
14 
15   set_actor("ac-blackball", 10,6.5, {player=0})

The resulting level looks like this inside the game:

The first level

Let's now turn to a line-by-line analysis of this "program":

 1   create_world(20, 13) 
 2   draw_border("st-brownie") 
 3   fill_floor("fl-hay", 0,0, level_width,level_height)

The first line creates a new world that is 20 blocks wide and 13 blocks high. Every "block" in the world can be accessed with a pair of coordinates: The upper left corner has coordinates (0,0), the lower right one has coordinates (19,12). Every block contains a floor tile, an (optional) item, and an (optional) stone.

A frame of stones is drawn around the newly created landscape with the draw_border command. Its argument, "st-brownie", is the name of a stone. By convention, all stones have "st-" prefixed to their name, similarly all item names begin with "it-" and all floor names with "fl-".

The fill_floor command in line 3 fills the complete floor with tiles of type "fl-hay". The other arguments are the upper left corner and the width and height of the rectangle to be filled.

 5   set_stone("st-fart", level_width-1,0, {name="fart"})
 6   set_stone("st-timer", 0,0, {action="trigger", target="fart",
 7             interval=10})

Lines 5 to 7 demonstrate how to create individual stones. The set_stone command takes a stone name, the desired coordinates, and an (optional) list of attributes as arguments. Note the use of curly braces "{", "}" to enclose the attribute list.

Attributes are the key to customizing the behaviour of objects in a landscape. Here, we first give a name to the first stone we create. It's a fart stone that has the unpleasant habit of "blowing off" when triggered. Triggering this fart stone is done by the timer stone we create in line 6-7. This stone performs a predefined action at regular intervals. In this case we want to send a "trigger" message every ten seconds to the object named "fart".

 9   oxyd(3,3)
10   oxyd(level_width-4,level_height-4)
11   oxyd(level_width-4, 3)
12   oxyd(3,level_height-4)
13   oxyd_shuffle()

These commands place a couple of oxyd stones in the level. The oxyd command internally uses set_stone("st-oxyd", x,y, ...) to create the stones, but it additionally assigns sensible values to some of the oxyd stones' attributes (most notably the color). The command on line 14 permutes the colors on the oxyd stones currently in the landscape.

15   set_actor("ac-blackball", 10,6.5, {player=0})

This final line creates the black marble controlled by the player. Objects that can move around freely are called actors in Enigma Unlike stones and items, actors are not restricted to integer coordinates, as you can see in this example. The final argument is, as usual, a list of attributes. In single-player levels this is always {player=0} for the black marble, in two-player levels you can use this attribute to assign actors to either player one or two.


Prev Table of Contents Next