-
Notifications
You must be signed in to change notification settings - Fork 4
LevelScripting
Alexandre Bodelot edited this page Jul 8, 2014
·
1 revision
Levels are defined in the following XML file: resources/xml/levels.xml
The level set is made of levels and functions, which are some kind of sub-levels. Both work the same, except functions are identified by a name, whereas levels are organized in an ordered sequence:
<?xml version="1.0" encoding="utf-8" ?>
<levelset>
<functions>
<def name="function_a">...</def>
<def name="function_b">...</def>
</functions>
<levels>
<level>... level 1 ...</level>
<level>... level 2 ...</level>
</levels>
</levelset>
Functions cannot be directly accessed from the game, and must be called from a level or from another function.
Each function is defined by a def
tag and a unique name
attribute.
Each level is defined by a level
tag. You can set the following attributes:
-
layer1
: path to the bottom background image -
layer2
: path to the top background image -
color
: color applied to the layers (HTML hex notation, example: "#3483b3") -
stars
: amount of stars scrolling in the background (integer) -
music
: path to music file
A level or a function contains the following tags:
-
ship
: create a spaceship-
id
: spaceship type (seexml/spaceships.xml
for more information) -
x
: initial x position -
y
: initial y position (screen right edge if not provided) -
t
: time to wait in seconds before spaceship is created, from the last created spaceship (0 if not provided)
-
-
asteroid
: create an asteroid-
x
,y
,t
: see above
-
-
boss
: create a end boss-
id
: boss type (hard coded string) -
x
,y
,t
: see above
-
-
decor
: create a decor with a fixed position-
id
: decor type (hard coded string) -
t
: see above
-
-
loop
: repeat all the inner tags-
count
: iteration count
-
-
call
: call a function-
func
: name of the called function
-
-
wait
: delay the next instruction-
t
: time to wait before the next instruction (seconds)
-
Using loops and functions allow factorizing repeated sequences, or sequences shared between several levels. You can use nested loops, and function calls inside functions.