API Reference
This page serves to document all the API functions that are available
for level designers of trackballs. Since it is currently under
construction it is not complete and you can find some more inforamtion
about the functions in existing levels or by looking in the
guile.cc
file in the source code.
Creating animated objects
These objects are any drawable and movable object in the world and a
number of API functions can be used to create them. See the section
below for functions to modify their properties.
(player)
Returns the current player as an 'animated' object
(new-mr-black x y)
Creates an opponend ball at specified position. Returns an 'animated' object.
(new-baby x y)
Creates a baby ball at specified position. Returns an 'animated' object.
(add-teleport x y dx dy radius)
Creates a teleporter at specified position with specified destination dx/dy expressed as absolute
coordinates. Radius is the size of the teleporter. Returns an 'animated' object.
(add-bird x y dx dy size speed)
Creates a bird at specified x/y position, with specified destination
dx/dy. Size and speed indicates the size of the bird and it's movement speed.
Returns an 'animated' object
(add-flag x y points visible radius)
Creates a flag giving points when captured. The x/y position in this
function is because of backwards compatibility given as an
INTEGER. Thus x=100 gives the coordinate 100.5. Returns an 'animated' object.
(add-colormodifier col x y min max freq phase)
Allow to modify the color(s) of a cell. Returns an 'animated' object.
(add-heightmodifier corner x y min max freq
phase n1 n2 n3)
Allow to modify the height of a cell's corner. Returns an 'animated' object
(add-cactus x y radius)
Creates a cactus at given position with given radius. Returns an
'animated' object.
(add-spike x y speed phase)
Creates a lethal spike going up and down. Returns an 'animated' object.
(add-sidespike x y speed phase side)
Creates a lethal spike (comming from the side). Returns an 'animated' object.
(add-goal x y rotate-p next-level)
Adds a new goal to the map. Orientation is given by rotate-p
(horizontal or vertical) and the next level to go to is given as a
string name (eg. "foo" to go to level "foo.map"). Returns an 'animated' object.
(sign text scale rotation duratin x y [z])
Creates a new sign with the given text/scale/rotatation. Duration
determines how long it lasts, if duration<0 then it lasts forever. The
last 'z' argument is optional. Returns an 'animated' object
(add-modpill x y kind length resurrecting)
Adds a new modpill at x,y with given kind. Kind must be one of the
'*mod-' varibles, see below, and determines the effect of the pill.
Length determines how long
it's effect lasts and resurrecting how long until the modpill
reappears on the map after it has been taken. Use resurrecting = 0 if
the pill can only be used once. Returns an 'animated' object
(forcefield x y z dx dy dz height allow)
Returns a forcefield extending from x,y,z to dx,dy,dz. The 'z'
arguments are given relative to the ground position. Height gives the
height of the forcefield and allow is the sum of one of *ff-nothing*,
*ff-kill1*, *ff-bounce1* and *ff-nothing*,
*ff-kill2*, *ff-bounce2*. This determines if nothing happens, if the
player is killed or bounces depending on in which direction he tries
to pass the force field. The flags *ff-kill* and *ff-bounce* are
shortcuts for (+ *ff-kill1* *ff-kill2*) and (+ *ff-kill1* *ff-kill2*)
respectively.
Returns an 'animated' object.
(switch x y on off)
Creates a switch at x/y with the two function 'on' and 'off' which are
called when the player toggles the switch to be on or off.
Returns an 'animated' object.
(pipe x0 y0 z0 x1 y1 z1 radius)
Creates a pipe going from x0/y0/z0 to x1/y1/z1 with the given radius. Returns an 'animated' object
(pipe-connector x0 y0 z0 radius)
Creates a new pipe connector. Returns an 'animated' object
(diamond x y [z])
Creates a new diamond 'save point'. Returns an 'animated' object
(fountain x y z rand-speed radius strength)
Creates a new fountain object. Returns an 'animated' object
Operations on animated objects
These functions can be applied to most animated objects returned by
the functions above in order to change their appearance, properties or
even trigger callbacks on specific events.
(set-position obj x y [z])
Sets the position of specified 'animated' object. Accepts optional z-coordinate.
(get-position-x obj)
Gets the X position of the specified 'animated' object.
(get-position-y obj)
Gets the Y position of the specified 'animated' object.
(get-position-z obj)
Gets the Z position of the specified 'animated' object.
(set-modtime obj mod time)
Alters time left for object (must be a ball or a pill) to have the
given modification. 'mod' is here one of the '*mod-' predefined
variables, see below.
(set-accelleration obj accel)
Sets acceleration of given computer controlled ball object (mr black
or baby) to make it easer/harder for the player.
(set-horizon obj horizon)
Sets AI horizon of given computer controlled ball object (mr black or
baby). The ball will not chase the player if he is beyond this distance.
(set-primary-color obj red green blue alpha)
Sets the primary colour of the object from the given colour
values. Values must be in the range 0.0 to 1.0. The actual drawing
effect depends on what type of object is beeing drawn but most objects
use this colour in their display.
(set-secondary-color obj red green blue alpha)
Sets the secondary colour of the object from the given colour
values. Values must be in the range 0.0 to 1.0. The actual drawing
effect depends on what type of object is beeing drawn. Not all objects
use this colour in their display.
(set-specular-color obj red green blue alpha)
Sets the specular (aka. "highlight") colour of the object from the given colour
values. Values must be in the range 0.0 to 1.0. The actual drawing
effect depends on what type of object is beeing drawn. Not all objects
use this colour in their display.
(set-flag obj flag state)
If state is true, then the given flag will be turned on for the
object. Otherwise it will be turned off. The available flags and the
results of the flags are dependent on the actual object used.
(set-wind pipe forward backward)
Sets the forward/backward wind of a pipe object. Can be used to force
the player to travel in one specific direction (or ease travells in
both) when entering a pipe. If forward is positive then it will be
easier to travell in the forward direction. If it is negative this
direction will be harder to travel in. If backwards is positive then it
will be harder to travel in that direction and if negative then
it will be easier.
(set-speed obj speed)
Alters the speed of platforms or spikes.
(set-texture obj texture-name)
Attempts to set the texture of an 'animated' object from the file with
the given name. Actual result depends on the object and not all
objects allows the use of a texture.
(set-fountain-strength obj str)
Sets the strength of a fountain object
(set-fountain-velocity obj vx vy vz)
Sets the velcity of outgoing droplets from a fountain object
(score-on-death obj points)
Score to award player when this object dies. Can be used to customize
how many points to be awarded when a ball/baby/bird/cactus/player
etc. dies. Passing the player argument as the object here can increse
or decrease the players points when he dies.
(time-on-death obj time)
Bonus time to award player when this object dies. Can be used to customize
how much time to be awarded when a ball/baby/bird/cactus/player
etc. dies. Passing the player argument as the object here can increse
or decrease the players time when he dies.
(default-on-death kind points time)
Sets the default score/time to be awarded when objects of the given
kind dies. The affects only objects created after this
function call. 'kind' must here be one of the '*score-' variables.
Creating hook objects
These objects make a continous change to the game but is generally not
drawn by themselves.
(add-cyclic-platform x1 y1 x2 y2 low high offset
speed)
Creates a new cyclic platform which modiies the map in the region
x1/y1 to x2/y2. This platform moves between the height value 'low' and
'high' with the given speed and time offset. Use offset to have
platform which move out of sync (harder for the player to pass).
(animator length position direction A B repeat
function)
These can be quite difficult to understand, so we shall describe these
like this:
Imagine a slider together with a marker you can position anywhere on
the slider. The slider has numbers on it,
on the left end it starts with some number value A and ends with value
B on the right end.
Furthermore, the marker on the slider can have a speed moving it right (positive speed) or left (negative speed).
When the marker hits one of the left/right ends it can either:
- Bounce
- Wrap over. ie. continue from the other end
- Stop
- Remove the slider and everything.
Now, connected to this virtual slider is a function which is called
whenever the marker has moved with the *value* which the marker
currently points at.
Ok, so that is how an "animator" object works. The slider analogy is
just for the explanation, nothing is displayed in the game, but
you can use it to make callbacks which alters the gameworld. For
some examples of what you can do with it see lv8.scm.
The behaviour can be the sum of
*animator-0-{remove,stop,bounce,wrap}* and
*animator-1-{remove,stop,bounce,wrap}* or simply
*animator-{remove,stop,bounce,wrap}* which has the same effect on both sides.
Operations on hook objects
Since all animated objects are also hook objects these functions can
be applied to most of the animated objects also. Eg, it is possible to
"turn off" a mr-black ball, or a switch etc.
(set-onoff obj state)
Turns the given hook object on or off depending on if the given state
is true or not.
(animator-value animator)
Returns the current value of animator object
(set-animator-direction animator direction)
Sets the speed and direction of the animator.
(set-animator-position animator direction)
Sets the position (0 .. length) for the position of the slider. This
is not the same as the value of the animator unless A/B happens
to be 0/1.
Global operations
These functions modify or read the global state of the game. Such as
turning on fog, or making it night etc.
(day)
Turns on the global light (day light).
(night)
Turns off the global light, making it night time.
(fog [strength])
Turns on fog in the game, with the given strength going from 0 to 2.
(fog-color r g b)
Gives the red/green/blue colour of the fog.
(set-bonus-level next-level)
Makes this level a "bonus level". This means that the level is exited
when the player dies and no life is lost.
(set-track-name name)
Gives the name of this level (aka. "track").
(set-author name)
Gives the name of the author for this track.
(start-time time)
Gives the starting time, in seconds, for this track.
(set-time time)
Sets the time left for the player (regardless of his current time).
(get-time)
Returns how much time the player has left.
(add-time time)
Adds the given amount of time to the player.
(set-score score)
Sets the score of the player.
(get-score)
Returns the current score of the player.
(add-score score)
Adds the given score to the player.
(set-start-position x y)
Sets the players starting position.
(snow strength)
Turns on snow. Strength must be in the range 0.0 to 1.0
(rain strength)
Turns on rain. Strength must be in the range 0.0 to 1.0
(difficulty)
Returns the difficulty we are currently playing on as an integer in
the range 0 (easy) to 2 (hard). See also the variables *easy*, *medium* and *hard*
which has these values.
(use-grid v)
Turns the grid on/off globally over the whole map.
(map-is-transparent state)
Turns on/off rendering of transparancy on the whole map. This uses
more CPU power and is turned off by default.
(jump strength)
Scales the maximum jump height of the player. If zero than the player
cannot jump, if eg. 2 then he can jump twice as high as normally.
(scale-oxygen strength)
Scales how long player can be under water.
(crash-tolerance strength)
Scales how resilient to crashes the player are. The higher this value
the stronger crashes he can take without dying and/or becomming
dizzy. The default value is 1.0.
(play-effect name)
Plays the sound effect in the given file name.
(camera-angle xy z)
Sets the cameras position as a rotation in the xy plane and in the
z plane.
(clear-song-preferences)
Removes all old music preferences.
(force-next-song)
Force a reload of songs.
(set-song-preference song weight)
Sets the weight for playing the given song.
Callbacks
General callback (hook) functions.
(trigger x y radius function)
Call the given function each tick when the player is within given radius from
x/y.
(smart-trigger x y entering-fn leaving-fn)
Call the given functions when the player enters or leaves the given
radius from the given position.
(on-event event subject function)
Register a function to be called when the given event occurs for
the given object. Callback must accept two arguments (subject and
object). Subject must be of type 'animated' or of type 'gameHook',
object is only used for some events (giving eg. who killed the
subject) and is otherwise false.
(get-event-callback)
Returns the callback currently registerd to the given object and event.
Map operations
These operations makes changes to the terrain of the level and can be
used to create custom events on the map.
(set-cell-flag x0 y0 x1 y1 flag state)
Turns on/off the given flag in all cells in the region x0/y0 to
x1/y1. Flag must here be one of the '*cell-' flags. See the list of
built-in variables for a list of suitable flags to modify.
Can be used to eg. dynamically change a region of the map to be icy,
or an acid etc.
(set-cell-velocity x0 y0 x1 y1 vx vy)
Modifies the velociy of the given cells. This is used primarily by
cells which have the "track" property set.
(set-cell-heights x0 y0 x1 y1 h0 h1 h2 h3 h4)
Modifies the height of the given cells. The heights are given as five
values corresponding to the four corners and the center point of the cell.
(set-cell-water-heights x0 y0 x1 y1 h0 h1 h2 h3 h4)
Modifies the water height of the given cells. If the water height is
higher than the normal height of a cell then it is under water.
The heights are given as five
values corresponding to the four corners and the center point of the cell.
(set-cell-colors x0 y0 x1 y1 corner r g b a)
Modifies the color of one corner of each of the given
cells. The corner modified is given by 'corner' and corresponds to one
of the '*cell-' flags with a direction (eg. *cell-ne*).
(set-cell-wall-colors x0 y0 x1 y1 corner r g b a)
Modifies the wall color of one corner of each of the given
cells. The corner modified is given by 'corner' and corresponds to one
of the '*cell-' flags with a direction (eg. *cell-ne*).
Constants
These functions modify or read the global state of the game. Such as
turning on fog, or making it night etc.
*mod-speed* *mod-jump* *mod-spike* *mod-glass*
*mod-dizzy* *mod-frozen* *mod-float* *mod-extra-life* *mod-large*
*mod-small* *mod-nitro*
Specifices modifications to be applied to a ball or to a modpill.
*easy* *normal* *hard*
Difficulty levels returned by the (difficulty) function.
*ff-nothing* *ff-kill1* *ff-bounce1* *ff-kill2*
*ff-bounce2* *ff-kill* *ff-bounce*
Specifies the behaviour of forcefields when moving through them in
direction 1 or direction 2. Use eg. (+ *ff-kill1* *ff-bounce2*) to die
when moving in direction 1 and bounce when moving in direction 2.
*soft-enter* *soft-exit*
Flags to be given to pipes to make it easier to enter/exit them.
*cell-ice* *cell-acid* *cell-sand* *cell-kill*
*cell-trampoline* *cell-nogrid* *cell-track*
Flags that can be given to cells modifying the terrain on them.
*animator-0-remove* *animator-0-stop*
*animator-0-bounce* *animator-0-wrap* *animator-1-remove* *animator-1-stop*
*animator-1-bounce* *animator-1-wrap* *animator-remove* *animator-stop*
*animator-bounce* *animator-wrap*
Specify the behaviour of an animator objects movement based on a sum
of these values.
*cell-ne* *cell-nw* *cell-se* *cell-sw*
*cell-center*
Gives the different corners of a cell.
*bird-constant-height*
If this flag is set to true for a bird then it will always fly at the
same height (not following the terrain).
*death* *spawn* *tick*
Events for which it is possible to trigger callbacks on most animated
objects. For now only the *death* events are working.
*score-player* *score-black* *score-baby*
*score-bird* *score-cactus* *score-flag*
Specifies a type of animated object to be used with the
default-on-death function.