This file is automatically generated, do not edit!
*** CONSTANTS ***
BLEND
REPLACE
RGB_ONLY
ALPHA_ONLY
ADD
SUBTRACT
MULTIPLY
AVERAGE
INVERT
LINE_MULTIPLE
LINE_STRIP
LINE_LOOP
SE_SINGLE
SE_MULTIPLE
SQUAREWAVE
SAWTOOTH
SINEWAVE
NOISE
EDGE_LEFT
EDGE_TOP
EDGE_RIGHT
EDGE_BOTTOM
PS_PARENT
PS_CHILD
PS_SHAPE_NULL
PS_SHAPE_RECTANGLE
PS_SHAPE_ELLIPSE
PS_ORIENTATION_EXPLICIT
PS_ORIENTATION_IMPLICIT
*** KEY_CONSTANTS ***
KEY_ESCAPE
KEY_F1
KEY_F2
KEY_F3
KEY_F4
KEY_F5
KEY_F6
KEY_F7
KEY_F8
KEY_F9
KEY_F10
KEY_F11
KEY_F12
KEY_TILDE
KEY_0
KEY_1
KEY_2
KEY_3
KEY_4
KEY_5
KEY_6
KEY_7
KEY_8
KEY_9
KEY_MINUS
KEY_EQUALS
KEY_BACKSPACE
KEY_TAB
KEY_A
KEY_B
KEY_C
KEY_D
KEY_E
KEY_F
KEY_G
KEY_H
KEY_I
KEY_J
KEY_K
KEY_L
KEY_M
KEY_N
KEY_O
KEY_P
KEY_Q
KEY_R
KEY_S
KEY_T
KEY_U
KEY_V
KEY_W
KEY_X
KEY_Y
KEY_Z
KEY_SHIFT
KEY_CAPSLOCK
KEY_NUMLOCK
KEY_SCROLLOCK
KEY_CTRL
KEY_ALT
KEY_SPACE
KEY_OPENBRACE
KEY_CLOSEBRACE
KEY_SEMICOLON
KEY_APOSTROPHE
KEY_COMMA
KEY_PERIOD
KEY_SLASH
KEY_BACKSLASH
KEY_ENTER
KEY_INSERT
KEY_DELETE
KEY_HOME
KEY_END
KEY_PAGEUP
KEY_PAGEDOWN
KEY_UP
KEY_RIGHT
KEY_DOWN
KEY_LEFT
KEY_NUM_0
KEY_NUM_1
KEY_NUM_2
KEY_NUM_3
KEY_NUM_4
KEY_NUM_5
KEY_NUM_6
KEY_NUM_7
KEY_NUM_8
KEY_NUM_9
MOUSE_LEFT
MOUSE_MIDDLE
MOUSE_RIGHT
MOUSE_WHEEL_UP
MOUSE_WHEEL_DOWN
JOYSTICK_AXIS_X
JOYSTICK_AXIS_Y
JOYSTICK_AXIS_Z
JOYSTICK_AXIS_R
PLAYER_1
PLAYER_2
PLAYER_3
PLAYER_4
PLAYER_KEY_MENU
PLAYER_KEY_UP
PLAYER_KEY_DOWN
PLAYER_KEY_LEFT
PLAYER_KEY_RIGHT
PLAYER_KEY_A
PLAYER_KEY_B
PLAYER_KEY_X
PLAYER_KEY_Y
*** MAP_ENGINE_CONSTANTS ***
COMMAND_WAIT
COMMAND_ANIMATE
COMMAND_FACE_NORTH
COMMAND_FACE_NORTHEAST
COMMAND_FACE_EAST
COMMAND_FACE_SOUTHEAST
COMMAND_FACE_SOUTH
COMMAND_FACE_SOUTHWEST
COMMAND_FACE_WEST
COMMAND_FACE_NORTHWEST
COMMAND_MOVE_NORTH
COMMAND_MOVE_EAST
COMMAND_MOVE_SOUTH
COMMAND_MOVE_WEST
SCRIPT_ON_CREATE
SCRIPT_ON_DESTROY
SCRIPT_ON_ACTIVATE_TOUCH
SCRIPT_ON_ACTIVATE_TALK
SCRIPT_COMMAND_GENERATOR
SCRIPT_ON_ENTER_MAP
SCRIPT_ON_LEAVE_MAP
SCRIPT_ON_LEAVE_MAP_NORTH
SCRIPT_ON_LEAVE_MAP_EAST
SCRIPT_ON_LEAVE_MAP_SOUTH
SCRIPT_ON_LEAVE_MAP_WEST
*** version functions ***
- Returns the current version of Sphere as a floating point number
(e.g. 1.0 or 1.1)
- Returns the current Sphere version string
*** configuration ***
- Get some global configuration options.
Parameter 'select' can be one of these: 0: language, 1: sound, 2: networking, 3: platform
return values for language:
0: default
1: English
2: German
3: French
4: Dutch
5: Japanese
6: Chinese_simplified
7: Russian
8: Spanish
9: Indonesian
return values for sound:
0: Sound Auto
1: Sound On
2: Sound Off
return values for networking:
0: No networking allowed
1: Networking is allowed
return values for platform:
0: Mac
1: Win32
2: Linux
*** script functions ***
- Reads the script in and uses it as if it were a part of the current script.
ex: EvaluateScript("myscript.js");
- Reads in one of the preset system scripts for use in the current script
ex: EvaluateSystemScript("menu.js");
- Reads the script in and uses it as if it were a part of the current script.
But only if the script has not already been evaluated.
ex: RequireScript("myscript.js");
- Reads in one of the preset system scripts for use in the current script.
But only if the script has not already been evaluated.
ex: RequireSystemScript("menu.js");
- invokes the JavaScript garbage collector
if given a parameter, then Sphere will decide if GC is required.
*** misc functions ***
- creates a single-character string based on the code passed in, i.e. 65 is "A"
Do not use this function, use String.fromCharCode(code) instead...
e.g. String.fromCharCode(65) == "A"
*** engine functions ***
- Returns array of game objects
- game.name Name of game
- game.directory Directory (project name) where game is stored
- game.author Who wrote it?
- game.description Bite-sized summary of game.
- executes the game in sphere/games/<directory>. This function
actually exits the first game and loads the one in 'directory'.
When the second game returns, the original is loaded again.
(Note that this is unlike Sphere 0.97, which returned directly
from ExecuteGame when the other game finished.)
- Exits the Sphere engine unconditionally
void Abort(
string message)
- Exits the Sphere engine unconditionally,
displays the 'message' to the user
If you end the message with a newline it wont display the file/line
where the Abort occured.
e.g. Abort("Mistake here")
vs. Abort("Game over!\n");
- restarts the current game
*** graphics functions ***
- displays the contents from the video buffer onto the screen.
Then the video buffer is cleared.
You *need* to call this to make anything
you've drawn in code to appear on the screen.
- Sets a clipping rectangle of width w and height h at (x, y) into the
video buffer. Anything drawn outside the rectangle is not drawn into
the video buffer.
- Returns a rectangle object representing the clipping rectangle.
i.e.
var clip = GetClippingRectangle();
clip.x
clip.y
clip.width
clip.height
- fills the whole screen with the color specified. Note that the color
passed must have an alpha that is less than 255. Otherwise, it'll
just make the screen solidly that color.
ApplyColorMask tints the screen's current state
(meaning you'll have to call it every frame
if you want the effect to be permanent)
- allows you to set the maximum frames rendered per second that
the engine is allowed to draw at most. Set to 0 in order to
unthrottle the graphics renderer. Keep in mind that this
is not for the map engine, which uses the fps specified in the
MapEngine() call. This function only controls standard drawing
functions and FlipScreen() outside of the map engine. In short,
don't use this function if you plan to be doing rendering in your
own scripts in the map engine.
- Returns the current fps set by SetFrameRate...
(note: this is not the same as the map engine frame rate)
- Sets the max frame rate (in frames per second) that the map engine will go at
- Returns the current map engine frames per second rate set by either MapEngine(map, fps) or SetMapEngineFrameRate(fps)
- returns the width of the engine screen
- returns the height of the engine screen
- plots a point onto the video buffer at (x, y) with the color
- plots a series of points onto the video buffer with the color
- draws a line from (x1, y1) to (x2, y2) with the color
- Draws a line from (x1, y1) to (x2, y2) with a color fade from color1
to color2
- Draws a series of lines with the color
- type = 0 = LINE_MULTIPLE: line list
- type = 1 = LINE_STRIP: line strip
- type = 2 = LINE_LOOP: line loop
- draws a Bezier curve from A(x1, y1) to C(x3, y3) with B(x2, y2) and D(x4, y4) as control points
- Draws a filled triangle with the points (x1, y1), (x2, y2), (x3, y3),
with the color c
- Draws a gradient triangle with the points (x1, y1), (x2, y2), (x3, y3),
with each point (c1 = color of (x1, y1), c2 = color of (x2, y2), c3 = color
of (x3, y3)) having a color to generate the gradient of the triangle
int PolygonCollision(
array arrA,
array arrB [,
int if (argc > 2) offsetAx,
int if (argc > 3) offsetAy,
int if (argc > 4) offsetBx,
int if (argc > 5) offsetBy])
- Determines if two polygons are colliding
It returns 0 when there is no collision, a positive number if a vertex of A
collides with B and a negative number is a vertex of B collides with A.
1 and -1 is the first point in the array, and so on. Because the first element
in an array is zero, you need to substract or add 1 to get the element number.
- Draws a color-filled polygon using the array of objects
(each object must have a 'x' and 'y' property).
If invert is true, all points in the bounding box of the polygon, but
not in the polygon will be colored.
- Draws an outlined rectangle at (x, y) of width w and height h and size size, filled with color c.
- Draws a rectangle at (x, y) of width w and height h, filled with color c.
- Draws a gradient rectangle at (x,y) with the height h and width w.
Each corner of a rectangle (c_ul = color of upper left corner,
c_ur = color of upper right corner, c_lr = color of lower right corner,
c_ll = color of lower left corner) accepts a color information to
generate the gradient of the rectangle.
- Draws an outlined ellipse at (x, y) with radius rx and ry
- Draws a filled ellipse at (x, y) with radius rx and ry
- Draws a filled rectangle at (r_x, r_y) with width r_w and height r_h and a circle cut out
of it at (circ_x, circ_y) with a radius of circ_r.
void FilledComplex(
int r_x,
int r_y,
int r_w,
int r_h,
int circ_x,
int circ_y,
int circ_r,
double angle,
double frac_size,
int fill_empty,
color_object color1,
color_object color2)
- Draws a filled rectangle at (r_x, r_y) with width r_w and height r_h and a circle
at (circ_x, circ_y) with a radius of circ_r (fractioned, if defined)
void GradientComplex(
int r_x,
int r_y,
int r_w,
int r_h,
int circ_x,
int circ_y,
int circ_r,
double angle,
double frac_size,
int fill_empty,
color_object color1,
color_object color2,
color_object color3)
- Draws a filled rectangle at (r_x, r_y) with width r_w and height r_h and a gradient circle
at (circ_x, circ_y) with a radius of circ_r (fractioned, if defined)
- Draws an outlined circle at (x, y) with radius r, filled with color c.
- Draws a filled circle at (x, y) with radius r, filled with color c.
- Draws a gradient circle at (x, y) with radius r, filled with internal color c1 and external color c2.
*** input ***
- returns true or false depending if the there are keys from the key
input queue.
- returns the first key in the queue. If there are no keys in the queue,
Sphere will wait until there is a key in the queue.
- checks if Caps Lock, Num Lock or Scroll Lock are active.
Allowed key values are:
KEY_CAPSLOCK
KEY_NUMLOCK
KEY_SCROLLOCK (note: only two Ls)
- checks if the key has been pressed.
Returns true if 'key' is pressed....
- checks if any key is pressed at the time.
- converts the key into a string, KEY_A will become "a", etc.
- if shift is true, returns uppercase/special value of key
- control keys return ""
- returns the key constant associated with the configurable player key of 'player'.
Allowed player values are 0 - 3 or:
PLAYER_1
PLAYER_2
PLAYER_3
PLAYER_4
Allowed player_key_constant values are:
PLAYER_KEY_MENU
PLAYER_KEY_UP
PLAYER_KEY_DOWN
PLAYER_KEY_LEFT
PLAYER_KEY_RIGHT
PLAYER_KEY_A
PLAYER_KEY_B
PLAYER_KEY_X
PLAYER_KEY_Y
- Sets the x and y of the mouse cursor
- returns the x location of the mouse cursor within the engine screen
- returns the y location of the mouse cursor within the engine screen
- returns true if the button is pressed
allowed button values are: MOUSE_LEFT, MOUSE_RIGHT, MOUSE_MIDDLE
- returns the first key in the queue for mouse wheel events
- returns the size of the queue for mouse wheel events
- returns the number of joysticks available on the system
- returns the number of axes available on this joystick
- returns the current position of the 'axis' axis of the joystick 'joy'
in normalized coordinates from -1 to 1
Axis values can be: JOYSTICK_AXIS_X, JOYSTICK_AXIS_Y, JOYSTICK_AXIS_Z, JOYSTICK_AXIS_R
- returns the number of buttons available on this joystick
- returns true if the button on joystick 'joy' is pressed
*** time ***
- returns the number of milliseconds since some arbitrary time.
ex:
var start = GetTime();
while (GetTime() < start + 1000) {}
*** particle engine ***
- returns a new particle system parent object
- returns a new particle system child object
*** networking ***
- returns a string with the local name of your computer
- returns a string with the IP address of your computer
- attempts to open a connection to the computer specified with 'address' on 'port'
returns a socket object
- listens for connections on port, returns a socket object if successful
*** byte_arrays ***
- returns a ByteArray object of 'size' bytes
- returns a ByteArray object from string 'string'
- returns a ByteArray object from string 'string'
*** colors ***
- returns a color object with the color r is Red, g is Green, b is Blue,
and a is alpha (translucency of the color).
Note + alpha of 0 = transparent, alpha of 255 = opaque
+ alpha is optional, and defaults to 255 if not specified
- returns a color object that is the blended color of color c1 and c2
- blends two colors together, allowing you to specify the amount of each color
ex:
BlendColorsWeighted(a, b, 1, 1) // equal amounts (like BlendColors())
BlendColorsWeighted(a, b, 1, 2) // 33% a, 66% b
*** mapengine ***
- starts the map engine with the map specified and runs at 'fps' frames per second
- changes current map
(This clears any pending delay scripts...)
- Returns the current map, e.g. "noisyforest.rmp"
- Exits the map engine. Note: This tells the map engine to shut
down. This does not mean the engine shuts down immediately. You
must wait for the original call to MapEngine() to return before you
can start a new map engine.
- Returns true if the map engine is running, false if not
- updates map engine (state of entities, color masks, etc.)
- calls a map's script from code
the six events are:
SCRIPT_ON_ENTER_MAP
SCRIPT_ON_LEAVE_MAP
SCRIPT_ON_LEAVE_MAP_NORTH
SCRIPT_ON_LEAVE_MAP_EAST
SCRIPT_ON_LEAVE_MAP_SOUTH
SCRIPT_ON_LEAVE_MAP_WEST
- set the default script that the map engine should call before calling the map's specific script
(The default map script is called, then the map specific script is called.)
The events are the same from CallMapScript.
The map engine doesn't have to be on to set a default script.
- Renders the map into the video buffer
- applies a color mask to things drawn by the map engine for 'num_frames' frames
- in 'num_frames' frames, runs 'script'
ex: SetDelayScript(60, "ChangeMap('forest.rmp')");
this tells the map engine to change to forest.rmp after 60 frames
- call the default map script
The events are the same from CallMapScript.
The map engine doesn't have to be on to call a default script.
*** layers ***
- get number of layers on map
- in the following functions, layer 0 is the bottommost layer.
- layer 1 is the next one up, etc.
- get width of 'layer'
- get height of 'layer'
- set width of 'layer'
- set height of 'layer'
- returns the name of 'layer'
- returns true if the layer is visible
- shows 'layer' if visible == true, and hides it if visible == false
e.g. SetLayerVisible(0, !IsLayerVisisble(0)); will toggle layer zero's visibility
- returns true if the layer is reflective
- sets whether layer should be reflective
- Sets the x zoom/scale factor for the layer 'layer_index' to 'factor_x'
e.g. SetLayerScaleFactor(0, 0.5) will make the layer zoom out to half the normal size
- Sets the y zoom/scale factor for the layer 'layer_index' to 'factor_y'
e.g. SetLayerScaleFactor(0, 2) will make the layer zoom in to twice the normal size
- Gets the angle (in radians) for the layer 'layer_index'
e.g. var angle = GetLayerAngle(0) will get the angle for the first layer
An angle of 0.0 is not rotated at all.
- Sets the angle (in radians) for the layer 'layer_index' to 'angle'
e.g. SetLayerAngle(0, Math.PI) will make the layer rotate slightly
*** tiles ***
- return number of tiles in map
void SetTile(
int x,
int y,
int layer,
int tile)
- changes tile on map to 'tile'
int GetTile(
int x,
int y,
int layer)
- returns tile on map
- returns the name of the tile 'tile_index'
- returns width in pixels of tiles on current map
- returns height in pixels of tiles on current map
- returns the image of the tile 'tile_index'
- sets the tile 'tile_index' to the image 'image_object'
- returns the surface of the tile 'tile_index'
- sets the tile 'tile_index' to the surface 'surface_object'
- gets the animation delay of the tile 'tile'
If it returns 0, the tile is not animated
- sets the animation delay of the tile 'tile' to 'delay'
A delay of 0 is considered not animated
- gets the next tile in the animation sequence of 'tile'
Note that if the return value is 'tile' the tile is not animated.
- sets the next tile in the animation sequence of 'tile' to 'new_tile'
SetNextAnimatedTile(tile, tile) turns off the tile animation for 'tile'
- Replaces all 'oldtile' tiles with 'newtile' on layer 'layer'
*** triggers ***
boolean IsTriggerAt(
int location_x,
int location_y,
int layer)
- Returns true if there is a trigger at map_x, map_y on layer. map_x
and map_y are in map (per-pixel) coordinates.
(Currently the layer parameter is ignored, although it still must be valid.)
- activates the trigger positioned on map_x, map_y, layer if one exists.
map_x and map_y are in map (per-pixel) coordinates.
[DISABLED]- returns the x value of the trigger in map (per-pixel) coordinates
[DISABLED]- returns the x value of the trigger in map (per-pixel) coordinates
[DISABLED]- returns the amount of triggers that there is
it will return the index of the trigger for which the current script
is running
*** zones ***
boolean AreZonesAt(
int location_x,
int location_y,
int layer)
- returns true if there are any zones at map_x, map_y on layer
(Currently the layer parameter is ignored, although it still must be valid.)
void ExecuteZones(
int location_x,
int location_y,
int layer)
- executes all the zones that map_x, map_y, layer is within
map_x and map_y are in map (per-pixel) coordinates.
(Currently the layer parameter is ignored, although it still must be valid.)
- executes the script for the zone 'zone'
- returns the amount of zones that there is
- best when called from inside a ZoneScript handler
it will return the index of the zone for which the current script
is running
- gets the x value of zone 'zone'
- gets the y value of zone 'zone'
- gets the width value of zone 'zone'
- gets the height value of zone 'zone'
- gets the layer value of zone 'zone'
- sets the layer value of zone 'zone'
- sets the dimensions of zone 'zone'
*** obstruction segments functions ***
- Returns the number of obstruction segments on the map...
*** input ***
void BindKey(
int key,
string on_down,
string on_up)
BindKey(key, onkeydown, onkeyup)
- runs the 'onkeydown' script when the 'key' is pressed down and runs
'onkeyup' when the 'key' is released
ex: BindKey(KEY_SPACE, "mode = 'in';", "mode = 'out';");
ex: BindKey(KEY_CTRL, "OnKeyPressed(KEY_CTRL)", "OnKeyReleased(KEY_CTRL)");
refer to keys.txt for a list of key names
- unbinds a bound key
- runs the 'on_down' script when the joystick 'button' is pressed down and runs
'on_up' when the joystick button is released
UnbindJoystickButton(joystick, button)
- unbinds a bound joystick button
- makes the 'person_entity' respond to the input
(up = KEY_UP, down = KEY_DOWN, left = KEY_LEFT, right = KEY_RIGHT)
- releases input from the attached person entity
- returns true if a person is attached to the input
- returns a string with the name of the person who currently holds input
- makes the 'person_entity' respond to the input
Keys vary based on player_index (0,1,2 or 3)
for now, only the up/down/left/right keys work. keyA, keyB, keyX and keyY are inoperative.
- releases input from the attached player entity
- calls 'script' after each frame (don't draw stuff in here!)
- calls 'script' after all map layers are rendered
- calls the rendering 'script' after 'layer' has been rendered.
Only one rendering script can be used for each layer of the map
- set the mask of 'layer' to 'mask'
e.g. SetLayerMask(0, CreateColor(255, 0, 0, 128)); will make the layer semi red
- get the mask currently being used by 'layer'
*** camera functions ***
- Attaches the camera view to specified person
- Detaches camera so it can be controlled directly
- returns true if the camera is attached to a person, false if the
camera is floating
- returns a string with the name of the person whom the camera
is attached to
- sets the x location of the camera object on the map
(the center of the screen if possible)
- sets the y location of the camera object on the map
(the center of the screen if possible)
- returns the x location of the camera object on the map
(the center of the screen if possible)
- returns the y location of the camera object on the map
(the center of the screen if possible)
- returns screen coordinates of position on map
- returns screen coordinates of position on map
- returns map coordinates of position on screen
- returns map coordinates of position on screen
*** person functions ***
- returns an array of strings representing the current person entities
(unnamed persons will not be in this list)
- Searches for person 'name' in the current person list and returns true if found.
void CreatePerson(
string name,
string spriteset,
boolean destroy_with_map)
- returns a person object with 'name' from 'spriteset'. If Sphere is
unable to open the file, the engine will give an error message and
exit. destroy_with_map is a boolean (true/false value), which the
spriteset is destroyed when the current map is changed if the flag
is set to true.
- destroys the person with the name
- sets the x position of the person on the map
- sets the y position of the person on the map
- sets the horizontal offset of the person on the map
- sets the vertical offset of the person on the map
- sets the position of the person with floating point accuracy
- sets the position of the person on the map
- gets the position of the person on the map
The position is based on the middle of the spriteset's base
rectangle.
- gets the position of the person on the map
The position is based on the middle of the spriteset's base
rectangle.
- gets the position of the person on the map
The position is based on the middle of the spriteset's base
rectangle.
- gets the position of the person on the map
The position is based on the middle of the spriteset's base
rectangle.
- gets the position of the person on the map
The position is based on the middle of the spriteset's base
rectangle.
- gets the position of the person on the map
The position is based on the middle of the spriteset's base
rectangle.
- gets the position of the person on the map
- Sets whether 'person' should ignore other spriteset bases
- Returns true if 'person' is ignoring person obstructions, else false
- Sets whether 'person' should ignore tile obstructions
- Returns true if 'person' is ignoring tile obstructions, else false
- Returns a list of people that 'name' is ignoring
- Tells 'name' to ignore everyone in list
e.g. SetPersonIgnoreList("White-Bomberman", ["bomb", "powerup"]);
Tells White-Bomberman to not be obstructed by bombs or powerups
- makes the sprite 'name' follow 'pixels' pixels behind sprite 'leader'.
If this function is called like:
FollowPerson(name, "", 0),
the person will detach from anyone it is following.
- sets which direction to show
- gets which direction is being shown
void SetPersonFrame(
string name,
int frame [,
boolean resetFrameDelay])
- sets which frame to show
It will retain the frame delay count of the previous frame, unless
the third optional parameter is false
- gets which frame is being shown
- sets the remaining frame delay for the current frame
- gets the remaining frame delay for the current frame
- sets the delay between when the person last moved and returning to
first frame. 0 disables this behaviour.
- gets the delay between when the person last moved and returning to
first frame. 0 disables this behaviour.
- sets the speed at which a person moves at
- sets the speed at which a person moves at
- gets the speed at which a person moves at
- gets the speed at which a person moves at
- gets the unitarian directional vector as a single number: x+(y<<2)
The directional vector is 0 when the person is not moving, use
historical to retrieve the previous value
Convert Vector to direction:
function V2D(v){
switch(v){
case -5: return 'northwest'; break;
case -4: return 'north'; break;
case -3: return 'northeast'; break;
case -1: return 'west'; break;
case 1: return 'east'; break;
case 3: return 'southwest'; break;
case 4: return 'south'; break;
case 5: return 'southeast'; break;
default: return '';
}
}
Convert Vector to coordinates:
function V2C(v){var y=(1+v>>2)&-1;return {x:v-(y<<2),y:y};}
- rescales the sprite to a certain scale specified by scale_w and scale_h.
Scaling is determined by floating point numbers like, 1.5 would scale
the person to 1.5 times its normal size based on his original sprite
size.
- rescales the sprite to width pixels and height pixels.
- gets a data object assiocated with the person 'name'
There are certain default properties/values filled in by the engine, they are:
num_frames - the number of frames for the person's current direction
num_directions - the number of directions for the person
width - the width of the spriteset's current frame
height - the height of the spriteset's current frame
leader - the person that this person is following, or "" if no-one...
destroy_with_map - if the person is destroyed with the map or not
obs_person - obstructed person index (-1 if not obstructed)
Any other properties are free for you to fill with values
e.g. var data = GetPersonData("Jimmy");
var num_frames = data["num_frames"];
note: Objects can not be stored, only numbers, booleans and strings.
void SetPersonData(
string name,
object data_object [,
string data.name])
- sets the 'data' object associated with the person 'name'
e.g.
var data = GetPersonData("Jimmy");
data["talked_to_jimmy"] = true;
SetPersonData("Jimmy", data);
note: Objects can not be stored, only numbers, booleans and strings.
- get a single person value. Example: GetPersonValue("Jimmy", "num_frames");
- set a person value. You can set boolean, numeric and string values
SetPersonValue("Jimmy", "talked_to_jimmy", true);
- returns the person's spriteset.
Although you can't add/delete directions, or add/delete frames you can change
ss.images[] - An array of images
ss.base.x1, ss.base.y1, ss.base.x2, ss.base.y2 - The _real_ obstruction base
ss.directions[0].name - the name of direction 0
ss.directions[0].frames[0].index - the index to images for the first frame
ss.directions[0].frames[0].delay - the delay showing that frame
- set's the person's spriteset to spriteset
e.g. SetPersonSpriteset("Jimmy", LoadSpriteset("jimmy.running.rss"));
- returns the person's base obstruction object. The values are sensitive to scaling,
unless you set 'real' to true.
The object contains the following properties: x1, x2, y1 and y2 (base coordinates)
You also can use GetPersonSpriteset and fetch the .base properties of it.
- Sets the person's base obstruction object.
Note: If the person is zoomed, you still need to define the base as if the person
was not scaled, and use SetPersonScaleFactor(person,GetPersonScaleFactor(person));
to update the base.
- returns the person's angle that is used
- sets the angle which the person should be drawn at
Note:
Zero is no rotation, and angles are in radians.
It does not rotate the spritesets obstruction base.
- sets a color multiplier to use when drawing sprites. if the color is
RGBA:(255, 0, 0, 255), only the red elements of the sprite are drawn.
If the color is RGBA:(255, 255, 255, 128), the sprite is drawn at
half transparency.
- returns the person's current mask
- returns the person's visible status
- sets the person's visible status, true = visible, false = not visible
e.g. SetPersonVisible(GetCurrentPerson(), !IsPersonVisible(GetCurrentPerson()));
- sets 'script' as the thing 'name' does in a certain event
the five events are
SCRIPT_ON_CREATE
SCRIPT_ON_DESTROY
SCRIPT_ON_ACTIVATE_TOUCH
SCRIPT_ON_ACTIVATE_TALK
SCRIPT_COMMAND_GENERATOR
(SCRIPT_COMMAND_GENERATOR will be called when the command queue for
the person runs out (for random movement thingies, etc))
- Gets 'script' as the thing 'name' does in a certain event
the five events are
SCRIPT_ON_CREATE
SCRIPT_ON_DESTROY
SCRIPT_ON_ACTIVATE_TOUCH
SCRIPT_ON_ACTIVATE_TALK
SCRIPT_COMMAND_GENERATOR
(SCRIPT_COMMAND_GENERATOR will be called when the command queue for
the person runs out (for random movement thingies, etc))
- sets 'script' as the thing that everyone does in a certain event
the five events are see above
- calls a person's script from code
'which' constants are the same as for SetPersonScript()
- best when called from inside a PersonScript handler
it will return the name of the person for whom the current script
is running
- adds a command to the person's command queue
the commands are:
COMMAND_WAIT
COMMAND_FACE_NORTH
COMMAND_FACE_NORTHEAST
COMMAND_FACE_EAST
COMMAND_FACE_SOUTHEAST
COMMAND_FACE_SOUTH
COMMAND_FACE_SOUTHWEST
COMMAND_FACE_WEST
COMMAND_FACE_NORTHWEST
COMMAND_MOVE_NORTH
COMMAND_MOVE_EAST
COMMAND_MOVE_SOUTH
COMMAND_MOVE_WEST
(note: these *might* change in a future release
'immediate', if true, will execute the command go right away
if false, it will wait until the next frame)
- adds a script command to the person's queue
- clears the command queue of sprite with the 'name'
- returns true if the person 'name' has an empty command queue
- returns -1 if name isn't obstructed by a tile at x, y,
- returns the tile index of the tile if name is obstructed at x, y
- returns "" if name isn't obstructed by person at x, y,
- returns the name of the person if name is obstructed at x, y
To check if more persons obstruct, move the first one away.
- returns true if person 'name' would be obstructed at (x, y)
- set key used to activate talk scripts
- get key used to activate talk scripts
- get button used to activate talk scripts
- set button used to activate talk scripts
- set distance to check for talk script activation
- get distance to check for talk script activation
- returns a spriteset object from 'filename'. If Sphere is unable to open
the file, the engine will give an error message and exit.
- returns a new spriteset.
*** Sound related functions ***
- returns a sound object from 'filename'. If Sphere is unable to open
the file, the engine will give an error message and exit. If the optional
argument 'streaming' is true or unspecified, the sound is streamed from the
hard drive. Otherwise, it's loaded into memory.
- returns a sound effect object from 'filename'. If Sphere is unable to open
the file, the engine will give an error message and exit.
There are two types of sound effects: SE_SINGLE and SE_MULTIPLE.
SE_SINGLE sound effects only allow the sound to be played once at a time.
SE_MULTIPLE sound effects always open a new stream to the audio device
for each time it is played (cleaning up or reusing old streams if possible).
- returns a sound from bytearray.
- returns a soundeffect from bytearray.
- returns an Sfxr object. The parameters are optional and can be set later on.
bitrate, samplerate, soundvolume, wavetype, basefrequency, minfrequency,
frequencyslide, frequencyslidedelta, squareduty, squaredutysweep, vibratodepth,
vibratospeed, attack, sustain, detay, release, filter, lowpassfiltercutoff,
lowpassfiltercutoffsweep, filterresonance, highpassfiltercutoff, highpassfiltercutoffsweep,
phaseroffset, phaseroffsetsweep, repeatspeed, arpeggio, arpeggiospeed
- Returns the name of the current map background music (could be a m3u list)
- Returns the type of the current map background music: 0: none 1: midi 2: wav/mp3/it/xm
- Starts the current map background music. If it is already playing, or doesnt exist, it does nothing.
Returns true if the music is playing
- Stops the current map background music. If it is already stopped, or doesnt exist, it does nothing.
Returns true if the music is stopped
- Tells us if the background music is playing
- Rewind the background music. (Can be slow on streamed music)
- Enable/Disable Loop the current background music (it is repeated by default)
Returns true if it succeeded setting the boolean value.
- Returns true if the current background music is looped. False if not.
- Sets the volume of the current background music. The volume can be 0 to 255.
- no effect on MIDIs
- Gets the volume of the current background music. The volume can be 0 to 255.
- no effect on MIDIs
- pan can be from -255 to 255. -255 = left, 255 = right. pan defaults to 0 (center).
- no effect on MIDIs
- returns the current pan of the sound (-255 to 255)
- no effect on MIDIs
- pitch ranges from 0.5 to 2.0. 0.5 is an octave down (and half as fast)
while 2.0 is an octave up (and twice as fast). pitch defaults to 1.0
- no effect on MIDIs
- returns the current pitch
- no effect on MIDIs
- returns true if the background music is seekable
- returns the length the background music. Music must be seekable.
- sets the position of the sound
if the sound isn't seekable, this does nothing
- gets the position of the sound
if the sound isn't seekable, this does nothing
*** Font functions ***
- returns a font object of the font that the engine currently uses.
- returns a font object from 'filename'. If Sphere is unable to open
the file, the engine will give an error message and exit.
*** windowstyle functions ***
- returns a windowstyle object of the windowstyle that the engine currently
uses.
- returns a windowstyle object from 'filename'. If Sphere is unable to open
the file, the engine will give an error message and exit.
- returns an image object of the System Arrow that the engine currently uses.
- returns an image object of the System Arrow(up) that the engine currently
uses.
- returns an image object of the System Arrow(down) that the engine
currently uses.
*** image functions ***
- returns an image object from 'filename'. If Sphere is unable to open or
read the image, the engine will give an error message and exit. The
image type that the engine supports are either PCX, BMP, JPG, and PNG.
- returns an image object from a section of the video buffer
defined by the parameters
- returns a surface object with width x height, filled with color
- returns a surface object with an image with the 'filename'
- returns a surface object captured from an area of the video buffer,
at (x, y) with the width w and height h.
colormatrix_object CreateColorMatrix(
int rn,
int rr,
int rg,
int rb,
int gn,
int gr,
int gg,
int gb,
int bn,
int br,
int bg,
int bb)
- Creates a colormatrix that is used to transform the colors
contained in a pixel with the following formula:
newcolor.red = rn + (rr * oldcolor.red + rg * oldcolor.green + rb * oldcolor.blue) / 255;
newcolor.green = gn + (gr * oldcolor.red + gg * oldcolor.green + gb * oldcolor.blue) / 255;
newcolor.blue = bn + (br * oldcolor.red + bg * oldcolor.green + bb * oldcolor.blue) / 255;
*** animation functions ***
- Returns an animation object with the filename. If Sphere is unable to
open the file, the engine will give an error message and exit. Sphere
supports animation formats of .flic, .fli, .flc and .mng, .jng
*** File related functions ***
boolean Rename(
string old_path,
string new_path)
- rename or move a file or directory
- create a new directory
- remove the specified directory
- remove the specified file.
This start from your game directory, so if you want to delete a logfile:
RemoveFile('logs/mylog.log');
- directory = directory in which to enumerate directories,
current game's directory if not specified
- returns an array of strings, which contains the directory names that resides
in the 'directory' directory of the game.
- directory = directory in which to enumerate files, "save" if not specified
- returns an array of strings, which contains the filenames that resides
in the 'directory' directory of the game.
- returns a file object with the filename. The file is created/loaded
from the "save" directory of the game. Note that any changes in the keys
will not be saved until the file object is destroyed.
- opens a file with the filename.
Unless writeable is true, the file *must* exist and reside
in the "other" directory of the game otherwise Sphere will give an error.
If the file is opened successfully, the function will return a rawfile
object. If the optional argument 'writeable' is true,
the contents of the file will be destroyed,
and you will be able to write to the file.
- opens a log file for use under the filename. If Sphere is unable to open
the file for logging, the engine will give an error message and exit.
If Sphere is successful in opening the file, it will return a log object
for use.
ex: var myLog = OpenLog("game.log");
- Gets the currently open mapengine object...
- generates an MD5 of the specified raw file, which, by backtracking
with a ../ may refer to any file within the game directory structure.
The result is a 32 character string containing the hexadecimal
representation of the resulting 128-bit MD5 fingerprint. Identical
files produce the same MD5 hash so it is an effective way to determine
if a file has become corrupt or altered
- generates an MD5 fingerprint as a hexadecimal string whose output
is the same as the RSA reference implementation of RFC 1321 which
means that the unix md5 command will return the same string for the
identical input. The resulting string contains the hexadecimal
representation of the MD5 fingerprint for the specified byte
array object
int DeflateFile(
string filename_source,
string filename_dest [,
int compressionlevel])
- Decompress a file to another file using deflate
The default base directory is other/, use ../ to reach other directories.
compressionlevel must be between 0 and 9, and is 6 by default
Returns zero on succes, nonzero if it failed.
The return numbers are (the constants are not defined in Sphere):
Z_OK 0
Z_STREAM_END 1
Z_NEED_DICT 2
Z_ERRNO (-1)
Z_STREAM_ERROR (-2)
Z_DATA_ERROR (-3)
Z_MEM_ERROR (-4)
Z_BUF_ERROR (-5)
Z_VERSION_ERROR (-6)
int InflateFile(
string filename_source [,
string filename_dest])
- Decompress a file to another file using deflate
The default base directory is other/, use ../ to reach other directories.
Returns zero on succes, nonzero if it failed. (same codes as DeflateFile)
- Compress a bytearray and return a deflated version.
compressionlevel must be between 0 and 9, and is 6 by default.
You can limit the maximum allowed size with maxsize.
Returns null on failure.
Note: for small strings, the compressed version could actually be bigger.
- Decompress a bytearray and return an inflated version.
You can limit the maximum allowed size with maxsize, if you don't
it will set an estimation for you, which could be too low.
Returns null on failure.
- returns an wrapper object filled with aging initialization parameters
- following signature is possible:
{min: -, max: -}
- accepts a wrapper object filled with aging initialization parameters to set
- the same parameters are accepted as returned by getAgingParams()
- parameters which should not be set, can be omitted
- returns a wrapper object filled with position initialization parameters
- if 'shape' is not specified, the parameters for the current shape are returned,
or if 'shape' is specified, the parameters belonging to the 'shape' are returned
- following signatures are possible:
{shape: PS_SHAPE_NULL}
{shape: PS_SHAPE_RECTANGLE,
x: {min: -, max: -},
y: {min: -, max: -}}
{shape: PS_SHAPE_ELLIPSE,
angle: {min: -, max: -},
a: {min: -, max: -},
b: {min: -, max: -}}
- accepts a wrapper object filled with position initialization parameters to set
- the same parameters are accepted as returned by getPosParams()
- parameters which should not be set, can be omitted
- if 'shape' is omitted, the parameters are assumed to belong to the current shape
- returns a wrapper object filled with velocity initialization parameters
- following signature is possible:
{mode: -,
angle: {min: -, max: -},
a: {min: -, max: -},
b: {min: -, max: -}}
mode can be either PS_ORIENTATION_EXPLICIT or PS_ORIENTATION_IMPLICIT
- accepts a wrapper object filled with position initialization parameters to set
- the same parameters are accepted as returned by getVelParams()
- parameters which should not be set, can be omitted
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ask particle system to update
- ask particle system to render
- adopt the particle_system
- host the particle_system, hosted systems' bodies are neither initialized nor updated
- return true, if the system is dead
- kills the system, this will trigger the on_death callback, if set
- revives the system, this will trigger the on_birth callback, if set
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- returns true if the socket is connected
- returns the size of the next array to be read in the socket
- reads from the socket, returns a ByteArray object
or returns null if it fails
e.g.
var data = socket.read(size);
if (data != null) {
// do stuff with data
}
- writes a ByteArray object into the socket
- closes the socket object, after this, the socket cannot be used.
- writes a string of text under the current block.
ex: myLog.write("Starting system...");
- creates a "block" which is indent inside the log with the name as the
title of the block. Any subsequent write commands will go under the newly
created block.
ex: myLog.beginBlock("Video Information");
- closes the current log block.
color.red
color.green
color.blue
color.alpha
- Colors must be between 0 and 255.
And are automatically clamped.
- exports the Color to a string, used internally by JSON
This string can be eval()'ed to recreate the color
spriteset.images
spriteset.directions[].name
spriteset.directions[].frames[].index
spriteset.directions[].frames[].delay
spriteset.base.x1
spriteset.base.y1
spriteset.base.x2
spriteset.base.y2
- saves the spriteset object to 'filename'
- returns a copy of the spriteset object
- plays the sound. repeat is a boolean (true/false), that indicates if
the sound should be looped
- pauses playback. call play() again to resume playback.
- stops playback
- resets playback
- no effect on MIDIs
- sets if the sound should be repeated
- returns true if sound is set to repeat, otherwise false
- sets the volume for the sound (0-255)
- no effect on MIDIs
- returns the sound's volume (0-255)
- no effect on MIDIs
- pan can be from -255 to 255. -255 = left, 255 = right. pan defaults to 0 (center).
- no effect on MIDIs
- returns the current pan of the sound
- no effect on MIDIs
- pitch ranges from 0.5 to 2.0. 0.5 is an octave down (and half as fast)
while 2.0 is an octave up (and twice as fast). pitch defaults to 1.0
- no effect on MIDIs
- returns the current pitch
- no effect on MIDIs
- returns true if the sound is currently playing
- returns true if the sound is seekable
Not all sound types are seekable, Ogg is.
- returns the position of the sound
returns zero if the sound isn't seekable
- sets the position of the sound
if the sound isn't seekable, this does nothing
- gets the length of the sound
- creates a copy of the sound object (currently doesn't really work)
- plays the sound effect.
If the sound effect is of type SE_SINGLE, this plays the sound
if it isn't playing yet, and starts it again if it is.
If the sound effect is of type SE_MULTIPLE, play() simply starts
playing the sound again.
- stops playback
If the sound is of type SE_SINGLE, stop the sound.
If it is of type SE_MULTIPLE, stop all playing instances of the sound.
- sets the volume for the sound effect (0-255)
- returns the sound effect's volume (0-255)
- pan can be from -255 to 255. -255 = left, 255 = right. pan defaults to 0 (center).
- returns the current pan of the sound effect
- pitch ranges from 0.5 to 2.0. 0.5 is an octave down (and half as fast)
while 2.0 is an octave up (and twice as fast). pitch defaults to 1.0
- returns the current pitch
- saves the sfxr as a wav file
It will use the ./sounds/ directory by default
- resets all the values of the sfxr object
- Creates a soundeffect. The parameter can be SE_MULTIPLE or SE_SINGLE
- Get the sample size
- Set the master volume of the sfxr object
- Get the master volume of the sfxr object
- Get the volume of the sfxr object
- Set the volume of the sfxr object
- Get the bitrate of the sfxr object
This value can be 8 or 16
- Set the bitrate of the sfxr object
This value can be 8 or 16
- Get the samplerate of the sfxr object
- Set the sample rate of the sfxr object
For example: 44100, 22500, 11000 or 8000.
Changing the samplerate effectively changes the pitch
- Get the wave type of the sfxr object
- Set the wave type of the sfxr object
Valid values are: SQUAREWAVE, SAWTOOTH, SINEWAVE and NOISE
- Get the base frequency of the sfxr object
- Set the base frequency of the sfxr object
This is for sliding the sound in pitch
Value must be between 0 and 1
- Get the minimal frequency of the sfxr object
- Set the minimal frequency of the sfxr object
Value must be between 0 and 1
- Get the frequency slide of the sfxr object
- Set the frequency slide of the sfxr object
Value must be between -1 and 1
- Get the frequency slide delta of the sfxr object
- Set the frequency slide delta of the sfxr object
Value must be between -1 and 1
- Get the square duty of the sfxr object
- Set the square duty of the sfxr object
Value must be between 0 and 1
- Get the square duty sweep of the sfxr object
- Set the square duty sweep of the sfxr object
Value must be between 0 and 1
- Get the vibrato depth of the sfxr object
- Set the vibrato depth of the sfxr object
Value must be between 0 and 1
- Get the vibrato speed of the sfxr object
- Set the vibrato speed of the sfxr object
Value must be between 0 and 1
- Get the vibrato delay of the sfxr object
- Set the vibrato delay of the sfxr object
Value must be between 0 and 1
- Get the attack envelope of the sfxr object
- Set the attack envelope of the sfxr object
Value must be between 0 and 1
- Get the sustain envelope of the sfxr object
- Set the sustain envelope of the sfxr object
Value must be between 0 and 1
- Get the decay envelope of the sfxr object
- Set the decay envelope of the sfxr object
Value must be between 0 and 1
- Get the release envelope of the sfxr object
- Set the release envelope of the sfxr object
Value must be between 0 and 1
- Get the filter of the sfxr object
- Set the filter of the sfxr object
Not sure what this does
- Get the low pass filter cutoff of the sfxr object
- Set the low pass filter cutoff of the sfxr object
Value must be between 0 and 1
- Get the low pass filter cutoff sweep of the sfxr object
- Set the low pass filter cutoff sweep of the sfxr object
Value must be between -1 and 1
- Get the filter resonance of the sfxr object
- Set the filter resonance of the sfxr object
Value must be between 0 and 1
- Get the high pass filter cutoff of the sfxr object
- Set the high pass filter cutoff of the sfxr object
Value must be between 0 and 1
- Get the high pass filter cutoff sweep of the sfxr object
- Set the high pass filter cutoff sweep of the sfxr object
Value must be between -1 and 1
- Get the phaser offset of the sfxr object
- Set the phaser offset of the sfxr object
Value must be between -1 and 1
- Get the phaser offset sweep of the sfxr object
- Set the phaser offset sweep of the sfxr object
Value must be between -1 and 1
- Get the repeat speed of the sfxr object
- Set the repeat speed of the sfxr object
Value must be between 0 and 1
- Get the arpeggio of the sfxr object
- Set the arpeggio of the sfxr object
Value must be between 0 and 1
- Get the arpeggio speed of the sfxr object
- Set the arpeggio speed of the sfxr object
Value must be between -1 and 1
- creates a copy of the sfxr object
- exports the Sfxr to a string, used internally by JSON
This string can be eval()'ed to recreate the sfxr.
note the float roundup: For .setBaseFrequency(0.123456789) the functions
.getBaseFrequency() returns 0.123456789104328156 and toJSON returns 0.123457
- Sets the color mask for a font
- Gets the color mask being used by the font object
- draws 'text' at x, y with the font
- draws scaled text (1.0 = normal) with (x,y) as the upper left corner
- draws a word-wrapped text at (x, y) with the width w and height h. The
offset is the number of pixels which the number of pixels from y which
the actual drawing starts at.
Note: 'text' can have the following special characters within it:
\n - newline
\t - tab
\" - double quote
\' - single quote
For example: font_object.drawTextBox(16, 16, 200, 200, 0, "Line One\nLine Two");
- Splits a string into an array of lines as if it were wrapped using
font_object.drawTextBox().
- returns the height of the font, in pixels
- returns the width of a given string, in pixels
- returns the height of the string as if it was drawn by drawTextBox
- returns a copy of the font object
- draws the window at (x, y) with the width and height of w and h.
Note that window corners and edges are drawn outside of the width
and height of the window.
- sets the color mask for a windowstyle
- gets the color mask being used by the windowstyle object
- [DISABLED] save the windowstyle object (this just returns false...)
- [DISABLED] clone the windowstyle object
- get the border size in pixels for the windowstyle object.
You can use EDGE_LEFT, EDGE_TOP, EDGE_RIGHT and EDGE_BOTTOM as parameters.
Note that the corner sizes are ignored.
image.width
image.height
void image.blit(
int x,
int y [,
int int blendmode])
- draws the image onto the video buffer at x,y
- draws the image into the video buffer, except that the color passed
as 'mask' tints the image
- draws the image into the video buffer, except that the image is rotates
in anti-clockwise in radians, which have a range of 0-2*pi.
(x,y) is the center of the blit.
- rotateBlit + mask
- draws the image into the video buffer with zooming, with the scaling
depending on factor. Normally a factor of 1 will blit a normal looking
image. Between 0 and 1 will shrink the image. Any values greater than 1
will stretch the size of the image.
- zoomBlit + mask
void image.transformBlit(
int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
int x4,
int y4 [,
int blendmode])
- draws the image into the video buffer with "transformation", where
(x1, y1) is the upper left corner, (x2, y2) the upper right corner,
(x3, y3) is the lower right corner, and (x4, y4) is the lower left
corner.
void image.transformBlitMask(
int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
int x4,
int y4,
color_object mask [,
int blendmode,
int mask_blendmode])
- transformBlit + blitMask
- returns a new surface object from the image
- returns a image object, which is a copy of this image object
surface.width
surface.height
- Apply the colormatrix to the pixels contained in x, y, w, h
- Apply 4 color matrixes. Each corner has a seperate color matrix.
- draws the surface to the video buffer at (x,y)
- draws 'surface' onto the surface_object at (x, y)
- draws 'surface' onto the surface_object at (x, y), except that the color passed
as 'mask' tints 'surface'
- draws 'surface' onto the surface_object at (x, y), except that 'surface' is rotated
anti-clockwise in radians, with -2*PI <= angle <= 2*PI
- rotateBlitSurface + blitMaskSurface
- draws 'surface' onto the surface_object at (x, y) with zooming, with the scaling
depending on factor. Normally a factor of 1 will draw a normal looking
'surface' and between 0 and 1 will shrink it. Any values greater than 1
will stretch it's size.
- zoomBlitSurface + blitMaskSurface
- draws 'surface' onto the surface_object with "transformation", where
(x1, y1) is the upper left corner, (x2, y2) the upper right corner,
(x3, y3) is the lower right corner, and (x4, y4) is the lower left
corner.
- transformBlitSurface + blitMaskSurface
- [DISABLED] draws 'image' onto the surface_object at (x, y)
- returns an image object from the surface object
- pass it one of the following constants:
- BLEND: DestColor = (DestColor * (255 - SrcAlpha) / 255) + ((SrcColor * SrcAlpha) / 255)
- ADD: DestColor = DestColor + ((SrcColor * SrcAlpha) / 255)
- SUBTRACT: DestColor = DestColor - ((SrcColor * SrcAlpha) / 255)
- MULTIPLY: DestColor = DestColor * ((SrcColor * SrcAlpha) / 255) / 255
- AVERAGE: DestColor = DestColor + ((SrcColor * SrcAlpha) / 255) / 2
- INVERT: DestColor = DestColor * (255 - ((SrcColor * SrcAlpha) / 255)) / 255
- REPLACE: DestColor = SrcColor
- RGB_ONLY: DestRGB = SrcRGB
- ALPHA_ONLY: DestAlpha = SrcAlpha
- returns the color of the pixel at (x,y)
- sets the pixel at (x,y) to 'color'
- sets the alpha of the surface
Set the second parameter to false to skip transparent pixels
- replace all pixels of the color oldColor in the surface with newColor
- Tells us if the color aColor is in the surface.
Returns an object containing x and y elements.
- Flood Fills the area with a color
- draws a series of points onto the surface
- draws a line onto the surface starting from (x1, y1) to (x2, y2) with
the color
- draws a gradient line onto the surface starting from (x1, y1) to (x2, y2)
- draws a series of lines onto the surface
- draws a Bezier Curve onto the surface
- draws an outlined rectangle onto the surface
- draws a filled rectangle onto the surface from (x, y) to (x+w, y+h)
with 'color'
- draws a filled triangle with the points (x1, y1), (x2, y2), (x3, y3),
with 'color'
- draws a filled gradient rectangle onto the surface from (x, y) to (x+w, y+h)
- draws a filled gradient triangle with the points (x1, y1), (x2, y2), (x3, y3),
- draws a filled polygon onto the surface
- draws an outlined ellipse onto the surface
- draws a filled ellipse onto the surface
- draws an outlined circle onto the surface
- draws a filled circle onto the surface
- draws a gradient circle onto the surface
- rotates the surface anti-clockwise with the range 0 - 2*pi. The resize
flag is a boolean to tell the engine to resize the surface if needed
to accomodate the rotated image.
this function returns the rotated object with the new .width and .height.
- resizes the surface images. This does not stretch or shrink the image
inside the surface.
this function returns the resized object with the new .width and .height.
- stretches or shrinks the surface to the new width w and height h
this function returns the rescaled object with the new .width and .height.
- flips the surface horizontally
- flips the surface vertically
- returns a surface object, which is a copy of this surface object
- returns a new surface object with the height and width of h and w, with
part of image at (x,y) from the surface_object with the width w and
height h.
void surface.applyLookup(
int x,
int y,
int w,
int h,
array rlookup,
array glookup,
array blookup,
array alookup)
The lookup parameters are arrays of 256 elements containg the new pixel values.
e.g. var invert_lookup = [255, 254, 253, 252, 251, ..., 4, 3, 2, 1, 0];
- draws 'text' at x, y with the font onto the surface_object
- draws scaled text (1.0 = normal) with (x,y) as the upper left corner
onto the surface_object
- draws a word-wrapped text at (x, y) onto the surface_object with the width w and height h.
The offset is the number of pixels which the number of pixels from y which
the actual drawing starts at.
See font_object.drawTextBox for more detail.
- saves the surface_object as a png image using the filename 'filename'
colormatrix.rn
colormatrix.rr
colormatrix.rg
colormatrix.rb
colormatrix.gn
colormatrix.gr
colormatrix.gg
colormatrix.gb
colormatrix.bn
colormatrix.br
colormatrix.bg
colormatrix.bb
- exports the ColorMatrix to a string, used internally by JSON
This string can be eval()'ed to recreate the colormatrix
animation.width
animation.height
animation.done
- returns the number of frames the animation contains.
- returns the amount of ticks
- returns the total playtime, if defined.
(FLC's dont have this property, MNG's do)
- returns the delay between frames, in milliseconds
- readies the next frame for drawing
- draws the current frame into the video buffer
- draws the current frame into the video buffer with a specified
zoom scale
void file.write(
string key,
any_type default_value)
- writes a value (string, number, boolean) to the file under the key name
any_type file.read(
string key,
any_type default_value)
- reads a value from the key
the value type returned depends on the default value.
+ if the default is a number, read will return a number.
+ if the default is a text or string, read will return a string.
+ if the default is a boolean, read will return a boolean
+ if the key is not present in the file, it will return the default value.
- returns the number of keys in the file
- returns a string of the key at 'index'
- writes the file to disk immediately... this way you don't have
to wait for it to save when the file object is garbage collected
- closes the file object, after this, the file_object cannot be used anymore.
- sets the position that the file will be read from
- returns the current position which the data is read from
- returns the number of bytes in the file
- reads the number of bytes that is specified by num_bytes. It will create
and return an array of data the rawfile object has read. The array of
data are numbers representation of each byte (0-255). Note that if the
number of bytes that will be read, exceeds the filesize from the current
position, it will only return an array of data of that is
actually read. The returned object is a ByteArray, so you can do
the same things with it as you can with any other ByteArray.
- writes the byte array to the file at the current position
The file must have been opened as writeable for this to work.
- closes the rawfile object, after this, the rawfile_object cannot be used anymore.
bytearray[index]
bytearray.length
- returns bytearray with bytearray_to_append attached to the end of it
- returns a slice of the bytearray starting at start, and ending at end
or the end of the bytearray if end is omitted.
If end is a negative number, the end point is started from the end of the bytearray.
-
- Adds a new layer filled with tile index
The mapengine must be running.
- [INTERNAL] appends num_tiles tiles to the tileset
- [INTERNAL] saves the tileset from the current map to ./maps/<filename>