-
Notifications
You must be signed in to change notification settings - Fork 86
Level Specification
Each level in the game is defined in a separate JSON file in the Levels directory. Each level file must have the following name format: level_(some number)_.json.
Each level has a format like this:
{ "level": { "id": "0", "name": "Tile test", "rivers": [ { "x": "17-23", "y": "18", "orient": "h" }, { "x": "17-23", "y": "12", "orient": "h" }, { "x": "17", "y": "12-18", "orient": "v" }, { "x": "23", "y": "12-18", "orient": "v" } ], "bridges": [ ], "houses": [ ] } }
Each level starts with a top node of level
which contains the following fields:
-
id
The ID of this level. This number must be unique amongst all the levels. The ID is also used when sorting the levels so a level withid
5 will show up in the menu before a level withid
6. -
name
The display name of this level. -
tiles
An optional field to specify an alternate tile count for this level.
In to those fields each level has the following objects:
The optional player element specifies the starting location of the player in this level. It specify the tile coordinates as an x
and y
like this:
"player": { "x": "6", "y": "20" }
If the starting position of the player isn't included then the player can choose where to start.
Each level may optionally specify a set of labels to explain details of the level. The labels are an array child of the level like this:
"labels": [ { "x": "22", "y": "27", "w": "16", "h": "10", "text": "Make sure to visit every house" } ]
Each label will grow vertically to support the text in the label.
The rivers
array specifies the location of each river in the level. Each river has an x
and y
coordinate and an orient
to specify if the bridge is vertical or horizontal.
{ "x": "5", "y": "5", "orient": "h" }
The valid values for orient
are h
for horizontal and v
for vertical.
Vertical rivers also support an additional optional property called side
. This value allows the river to add an extra sprite to the top and bottom to make a nice connection with a rounded border. The valid values are left
and right
.
The bridges
array specifies places where the player can cross rivers. Each bridge has an x
and y
coordinate in addition to the following fields:
-
dir
The direction of the bridge. This optional value restricts the player to only cross the bridge in one direction. Valid values areup
,left
,down
, andright
. -
orient
The orientation of the bridge. Eitherh
for horizontal orv
for vertical. -
color
The optional color of the bridge. Valid colors arered
,green
,blue
, andorange
-
coins
The optional number of coins required to completely cross this bridge.
{ "x": "8", "y": "15", "orient": "h", "color": "green" }
The bridge4s
array specifies 4-way bridges in the level. 4-way bridges have only an x
and y
coordinate
{ "x": "c", "y": "m" }
The houses
array specifies houses the player can visit in the level. Each house has an x
and y
coordinate in addition to the following fields:
-
color
The optional color of the bridge. Valid colors arered
,green
,blue
, andorange
-
coins
The optional number of coins available at this house
Objects in each level are placed at an X,Y coordinate based on a tile system that is 42 tiles wide and 28 tiles tall. Placing an item at 0,0 puts it in the lower left corner and placing it at 42,28 places it in the top right corner.
In addition to specifying a specific number for coordinates levels also support the following constants:
-
l
The left side of the screen -
b
The bottom of the screen -
r
The right side of the screen -
t
The top of the screen -
m
The vertical middle of the screen -
c
The horizontal center of the screen
Rivers can also specify their X,Y coordinates as ranges. Each range must start with the small value and end with the larger value.
A river across the middle of the screen horizontally
{ "x": "l-r", "y": "m", "orient": "h" }
A river across the middle of the screen vertically
{ "x": "c", "y": "b-t", "orient": "v" }