Methods
-
Key(scancode)
-
Direct keyboard input through Allegro's key.
Only recommended to let the user pick keyboard controls: use "buttons[player]" and "dpad[player]" for game input.Parameters:
Name Type Description scancode
Integer - Source:
Returns:
Whether the key is pressed (value of key[scancode])
- Type
- Boolean
-
ReadKey()
-
Direct keyboard input through Allegro's keypressed and readkey.
Contrary to readkey, doesn't wait for a keypress, always returning immediately.
Only recommended to let the user pick keyboard controls: use "buttons[player]" and "dpad[player]" for game input.- Source:
Returns:
0 if no key is pressed, scancode otherwise
- Type
- Integer
-
ReadKeyASCII()
-
Direct keyboard input through Allegro's keypressed and readkey.
Contrary to readkey, doesn't wait for a keypress, always returning immediately.- Source:
Returns:
-1 if no key is pressed, ASCII code otherwise (affected normally by shift, ctrl, capslock etc)
- Type
- Integer
-
Joystick(id)
-
Direct joystick input (through Allegro's "joy").
Only recommended to let the user pick joystick controls: use "buttons[player]" and "dpad[player]" for game input.Parameters:
Name Type Description id
Integer Joystick id, from 0 to a max of 16
- Source:
Returns:
A Javascript object tree equivalent to Allegro's JOYSTICK_INFO
- Type
- Object
-
Cout()
-
Similar to console.log, a text output function for debugging.
Contrary to usual console.log behaviour, file, line and time are not printed.
This is a variadic function taking any number of arguments.- Source:
-
Quit()
-
Will close the program normally, after completing the frame (i.e. after Loop returns). Execution does continue after the call.
- Source:
-
Restart()
-
Will restart the game, after completing the frame (i.e. after Loop returns).
- Source:
-
Arc(bitmap, x, y, ang1, ang2, r)
-
Allegro's arc.
Draws a circular arc with centre x, y and radius r, in an anticlockwise direction starting from the angle a1 and ending when it reaches a2.
These values are specified with 256 equal to a full circle, 64 a right angle, etc. Zero is to the right of the centre point, and larger values rotate anticlockwise from there.Parameters:
Name Type Description bitmap
Bitmap x
Integer y
Integer ang1
Fixed ang2
Fixed r
Integer - Source:
-
Circle(bitmap, x, y, radius, color)
-
Allegro's circle.
Parameters:
Name Type Description bitmap
Bitmap x
Integer y
Integer radius
Integer color
Integer - Source:
-
CircleFill(bitmap, x, y, radius, color)
-
Allegro's circlefill. Like Circle, but with the insides filled in.
Parameters:
Name Type Description bitmap
Bitmap x
Integer y
Integer radius
Integer color
Integer - Source:
-
ClearToColor(bitmap, colour)
-
Allegro's clear_to_color. Fills the passed bitmap with the specified colour.
Parameters:
Name Type Description bitmap
Bitmap colour
Integer - Source:
-
Ellipse(bitmap, x, y, radiusX, radiusY, color)
-
Allegro's ellipse.
Parameters:
Name Type Description bitmap
Bitmap x
Integer y
Integer radiusX
Integer radiusY
Integer color
Integer - Source:
-
EllipseFill(bitmap, x, y, radiusX, radiusY, color)
-
Allegro's circlefill. Like Ellipse, but with the insides filled in.
Parameters:
Name Type Description bitmap
Bitmap x
Integer y
Integer radiusX
Integer radiusY
Integer color
Integer - Source:
-
FloodFill(bitmap, x, y, colour)
-
Allegro's floodfill.
Parameters:
Name Type Description bitmap
Bitmap x
Integer y
Integer colour
Integer - Source:
-
HLine(bitmap, x1, y, x2, colour)
-
Allegro's hline.
Parameters:
Name Type Description bitmap
Bitmap x1
Integer y
Integer x2
Integer colour
Integer - Source:
-
Line(bitmap, x1, y1, x2, y2, colour)
-
Allegro's line.
Parameters:
Name Type Description bitmap
Bitmap x1
Integer y1
Integer x2
Integer y2
Integer colour
Integer - Source:
-
PutPixel(bitmap, x, y, colour)
-
Allegro's putpixel.
Parameters:
Name Type Description bitmap
Bitmap x
Integer y
Integer colour
Integer - Source:
-
Rect(bitmap, x1, y1, x2, y2, colour)
-
Allegro's rect.
Parameters:
Name Type Description bitmap
Bitmap x1
Integer y1
Integer x2
Integer y2
Integer colour
Integer - Source:
-
RectFill(bitmap, x1, y1, x2, y2, colour)
-
Allegro's rectfill. Like Rect, but with the insides filled in.
Parameters:
Name Type Description bitmap
Bitmap x1
Integer y1
Integer x2
Integer y2
Integer colour
Integer - Source:
-
Triangle(bitmap, x1, y1, x2, y2, x3, y3, colour)
-
Allegro's triangle. Draws a filled triangle (unlike what you'd expect from other primitives, there is no TriangleFill).
Parameters:
Name Type Description bitmap
Bitmap x1
Integer y1
Integer x2
Integer y2
Integer x3
Integer y3
Integer colour
Integer - Source:
-
VLine(bitmap, x, y1, y2, colour)
-
Allegro's vline.
Parameters:
Name Type Description bitmap
Bitmap x
Integer y1
Integer y2
Integer colour
Integer - Source:
-
GetPixel(bitmap, x, y)
-
Allegro's getpixel.
Parameters:
Name Type Description bitmap
Bitmap x
Integer y
Integer - Source:
Returns:
Colour value
- Type
- Integer
-
PutPixelBatch(bitmap, rle, buf)
-
Puts a batch of pixels at once into the passed bitmap.
There is an option to use RLE, in which case, runs of colours will be written filling horizontal lines, with a single starting position for each run of colour values. Otherwise, there is a position and colour triplet for each pixel.Parameters:
Name Type Description bitmap
Bitmap rle
Boolean Whether RLE is used
buf
Int32Array A typed array, elements are in a [x, y, n, c1, c2, c3, ... , cn, x, y, n, c1, c2, ...] format if RLE is used or [x1, y1, c1, x2, y2, c2, x3, y3, c3, ...] if not
- Source:
-
CreateBitmap(width, height)
-
Creates a bitmap object through Allegro's create_bitmap.
Parameters:
Name Type Description width
Integer height
Integer - Source:
Returns:
- Type
- Bitmap
-
CreateBitmapEx(coldepth, width, height)
-
Creates a bitmap object through Allegro's create_bitmap_ex.
Difference from @CreateBitmap is that it specifies color depth.
Has use to create temporary transfer areas between color depths, making use of Allegro's color conversion stuff - for example, transfer a 8bit image into a 32bit bitmap, apply truecolor effects to it and then move it back to the 8bit one.Parameters:
Name Type Description coldepth
Integer width
Integer height
Integer - Source:
Returns:
- Type
- Bitmap
-
CreateSubBitmap(bmp, x, y, w, h)
-
Creates a subbitmap through Allegro's create_sub_bitmap.
Those share memory, etc. and drawing to a subbitmap will affect the corresponding area in the source bitmap.
Useful for example to separate the screen in areas dynamically without keeping displacements in every draw call.
The returned bitmap will have the "parent" property set to the source bitmap.Parameters:
Name Type Description bmp
Bitmap x
Integer X coordinate of subbitmap, currently can be any value, however eventually care may need to be taken that multiple of 4 aligned values be used when taking subbitmaps of screen
y
Integer As above, including alignment issue
w
Integer h
Integer - Source:
Returns:
- Type
- Bitmap
-
LoadBitmap(filename)
-
Loads a bitmap through Allegro's load_bitmap.
The palette generated by Allegro together with loading the bitmap is discarded.
Returns null on failures such as file not found.Parameters:
Name Type Description filename
String - Source:
Returns:
- Type
- Bitmap
-
SaveBitmap(filename, bitmap)
-
Saves a bitmap through Allegro's save_bitmap.
If the program is running on 8bit colour depth, the palette used is the currently set global palette.Parameters:
Name Type Description filename
String bitmap
Bitmap - Source:
-
DrawBitmap(bmp, spr, X, Y)
-
Allegro's draw_sprite. Draws the whole bitmap at the specified position.
Note that DrawSprite et al. is of different use.Parameters:
Name Type Description bmp
Bitmap Bitmap drawed on
spr
Bitmap Bitmap drawed
X
Integer Y
Integer - Source:
-
DrawTransformBitmap(bitmap, spr, transforms [, angle] [, scale] [, flip])
-
Allegro's rotate_scaled_sprite et al. Draws the whole bitmap at the specified position.
Rotation, scaling and flipping are optional transforms.
Note that DrawTransformSprite is of different use.Parameters:
Name Type Argument Description bitmap
Bitmap Bitmap drawed on
spr
Bitmap Bitmap drawed
transforms
Integer Binary flags for transforms used (SPRITE_FLIP, SPRITE_ROTATE, SPRITE_SCALE)
angle
Fixed <optional>
256.0 is a full rotation
scale
Fixed <optional>
2.0 is double the size
flip
Integer <optional>
Binary flags (FLIP_V, FLIP_H)
- Source:
-
DrawBlendedBitmap(bmp, spr, X, Y, blender)
-
Allegro's draw_trans_sprite/draw_lit_sprite. Draws the whole bitmap at the specified position, with specified blending function.
Note that DrawSprite et al. is of different use.Parameters:
Name Type Description bmp
Bitmap Bitmap drawed on
spr
Bitmap Bitmap drawed
X
Integer Y
Integer blender
Integer If negative, transparency blending is used, otherwise this is the light level for light blending or color for colortable blending (0 to 255)
- Source:
-
LoadPalette(filename)
-
Loads a palette from an image file using Allegro's load_bitmap.
Returns null on failures such as file not found.Parameters:
Name Type Description filename
String - Source:
Returns:
- Type
- Palette
-
LastBitmapPalette()
-
Returns the palette from the last bitmap loaded.
- Source:
Returns:
- Type
- Palette
-
SetPalette(pal)
-
Sets the current screen palette using Allegro's set_palette. For 8-bit colour modes only.
Parameters:
Name Type Description pal
Palette - Source:
-
MakeCol(r, g, b)
-
Allegro's makecol.
Converts colors from a hardware independent format (red, green, and blue values ranging 0-255) to the pixel format required by the current video mode, calling the preceding 8, 15, 16, 24, or 32 bit makecol functions as appropriate.
Parameters:
Name Type Description r
Integer g
Integer b
Integer - Source:
-
ReadFile(filename)
-
Reads a binary file and returns its contents.
Returns null on any failures.Parameters:
Name Type Description filename
String - Source:
Returns:
Plain DukTape buffer containing the file's contents.
- Type
- Buffer
-
ReadTextFile(filename)
-
Reads a text file and returns its contents.
Returns null on any failures.Parameters:
Name Type Description filename
String - Source:
Returns:
String containing the file's contents.
- Type
- String
-
WriteFile(filename, buf)
-
Writes to a binary file. Previous file contents are discarded.
Parameters:
Name Type Description filename
String buf
Buffer Plain DukTape buffer with contents to be written.
- Source:
-
WriteTextFile(filename, str)
-
Writes to a text file. Previous file contents are discarded.
Parameters:
Name Type Description filename
String str
String Content to be written.
- Source:
-
FileTime(filename)
-
Returns the time a file was last modified. Behaviour is not well known if the file doesn't exist.
Parameters:
Name Type Description filename
String - Source:
Returns:
Likely to be a POSIX time
- Type
- Integer
-
FileExists(filename)
-
Checks for existence of a file. Ignores directories, system files, hidden files, ....
Parameters:
Name Type Description filename
String - Source:
Returns:
- Type
- Boolean
-
ListFiles(wildcard)
-
Lists all files matching the specified wildcard. Useful for example to load all map files within a subdirectory. Will retrieve a max of 1024 files.
Parameters:
Name Type Description wildcard
String - Source:
Returns:
Array of filename strings
- Type
- Array
-
GetConfig(configs)
-
Get configuration values using Allegro's get_config_float, get_config_int and get_config_string.
Parameters:
Name Type Description configs
Object Will be modified to contain the values read. Example:
Properties
Name Type Argument Default Description a_value
Number <optional>
5 Reads a floating point value from the root of the config file, with default value 5.0
a_section
Object A [section] in the config file
Properties
Name Type Argument Default Description another_value
String <optional>
"Test" Reads a string value from a section called "a_section", with default value "Test"
- Source:
-
SetConfig(configs)
-
Set configuration values using Allegro's set_config_float, set_config_int and set_config_string. Same deal as GetConfig.
Won't actually write to the configuration file until Tapegro closes.Parameters:
Name Type Description configs
Object Will be written to config file. Example:
Properties
Name Type Argument Default Description a_value
Number <optional>
5 Writes "a_value = 5.0" (in the root of the config file i.e. the top with no section above)
a_section
Object Writes [a_section] in the config file
Properties
Name Type Argument Default Description anoter_value
String <optional>
"Test" Writes "another_value = 'Test'"
- Source:
-
TextOut(bmp, text, x, y, fg)
-
Allegro's textout.
Unlike the actual textout, the font used is implicit through SetFont. Use SetTextBgColor to select the background color used with this function.Parameters:
Name Type Description bmp
Bitmap Bitmap written on
text
String Text
x
Integer X
y
Integer Y
fg
Integer Text colour, or if -1 and a colour font is in use, text is drawn with colours from the original font image for multicoloured text
- Source:
-
SetTextAllign(allign)
-
Selects between left-alligned, right-alligned and centred text (Allegro's textout, textout_right and textout_centre).
Parameters:
Name Type Description allign
Integer TEXT_LEFT, TEXT_RIGHT or TEXT_CENTER
- Source:
-
SetTextBgColor(bg)
-
Sets the background color for text written with TextOut. Default is 0.
Parameters:
Name Type Description bg
Integer Background colour, or -1 for transparent
- Source:
-
LoadFont(filename)
-
Reads a text file and returns its contents.
Returns null on any failures.Parameters:
Name Type Description filename
String - Source:
Returns:
- Type
- Font
-
SetFont(font)
-
Sets the font used by TextOut.
The font is also written to the "currentFont" variable. Overwriting this global directly can cause memory issues with impredictable results including crashes and corruption, plus it will be ignored by TextOut.Parameters:
Name Type Description font
Font - Source:
-
Blit(src, dest, sx, sy, dx, dy, w, h)
-
Allegro's blit. Blit essentially copies an area of an image into another, including transparent colour values (0 for 8-bit depths, 0xFF00FF magic pink, etc.).
Additionally, blit performs colour depth conversion between bitmaps.Parameters:
Name Type Description src
Bitmap Source bitmap
dest
Bitmap Destination bitmap
sx
Integer Source X
sy
Integer Source Y
dx
Integer Destination X
dy
Integer Destination Y
w
Integer Width of area copied
h
Integer Height of area copied
- Source:
-
StretchBlit(src, dest, sx, sy, sw, sh, dx, dy, dw, dh)
-
Allegro's stretch_blit. Like Blit but also stretches the source area into the destination area.
Parameters:
Name Type Description src
Bitmap Source bitmap
dest
Bitmap Destination bitmap
sx
Integer Source X
sy
Integer Source Y
sw
Integer Source width
sh
Integer Source height
dx
Integer Destination X
dy
Integer Destination Y
dw
Integer Destination width
dh
Integer Destination height
- Source:
-
MaskedBlit(src, dest, sx, sy, dx, dy, w, h)
-
Allegro's masked_blit. Like Blit but ignores transparent pixels.
Parameters:
Name Type Description src
Bitmap Source bitmap
dest
Bitmap Destination bitmap
sx
Integer Source X
sy
Integer Source Y
dx
Integer Destination X
dy
Integer Destination Y
w
Integer Width of area copied
h
Integer Height of area copied
- Source:
-
MaskedStretchBlit(src, dest, sx, sy, sw, sh, dx, dy, dw, dh)
-
Allegro's masked_stretch_blit.
Parameters:
Name Type Description src
Bitmap Source bitmap
dest
Bitmap Destination bitmap
sx
Integer Source X
sy
Integer Source Y
sw
Integer Source width
sh
Integer Source height
dx
Integer Destination X
dy
Integer Destination Y
dw
Integer Destination width
dh
Integer Destination height
- Source:
-
CreateSpriteSheet(bitmap, w, h)
-
Creates a sprite sheet object, which is used by other sprite functions.
All frames will have equal width and height as passed. Frame 0 will be at the top left corner, frame indices grow from left to right and then from top to bottom.Parameters:
Name Type Description bitmap
Bitmap Bitmap containing the sprite's frames
w
Integer Width of one frame
h
Integer Height of one frame
- Source:
Returns:
Created sprite sheet
- Type
- Spritesheet
-
DrawSprite(bitmap, ss, x, y, f)
-
Draws a frame from a sprite sheet into the bitmap at the specified position.
Parameters:
Name Type Description bitmap
Bitmap Bitmap drawed on
ss
SpriteSheet Spritesheet object
x
Integer X
y
Integer Y
f
Integer Frame index
- Source:
-
DrawBlendedSprite(bitmap, ss, x, y, f, blender)
-
An extension of DrawSprite. Does blending just like DrawBlendedBitmap.
Parameters:
Name Type Description bitmap
Bitmap Bitmap drawed on
ss
SpriteSheet Spritesheet object
x
Integer X
y
Integer Y
f
Integer Frame index
blender
Integer If negative, transparency blending is used, otherwise this is the light level for light blending or color for colortable blending (0 to 255)
- Source:
-
DrawTransformSprite(bitmap, ss, transforms, X, Y, f [, angle] [, scale] [, flips])
-
An extension of DrawSprite.
Uses Allegro's rotate_scaled_sprite et al. Rotation, scaling and flipping are optional transforms.Parameters:
Name Type Argument Description bitmap
Bitmap Bitmap drawed on
ss
SpriteSheet Spritesheet object
transforms
Integer Binary flags for transforms used (SPRITE_FLIP, SPRITE_ROTATE, SPRITE_SCALE)
X
Integer Y
Integer f
Integer Frame index
angle
Fixed <optional>
256.0 is a full rotation
scale
Fixed <optional>
2.0 is double the size
flips
Integer <optional>
Binary flags (FLIP_V, FLIP_H)
- Source:
-
DrawSpriteBatch(bitmap, ss, mode, buf)
-
A batch version of DrawSprite. Allows larger numbers of sprites without performance hits.
There is no DrawTransformSpriteBatch nor DrawBlendedSpriteBatch as this function does both.
Unlike DrawTransformBitmap, which can't blend its bitmaps, this function can also do batches of blended sprites.
Blending and transforms cannot be used simultaneously.Parameters:
Name Type Description bitmap
Bitmap Bitmap drawed on
ss
SpriteSheet Spritesheet object
mode
Integer Either SPRITE_BLEND or binary flags for transforms used (SPRITE_FLIP, SPRITE_ROTATE, SPRITE_SCALE)
buf
Int32Array Buffer with several sprites, like the following (values with may be omitted according to mode flags): [X, Y, frame index, blender, angle, scale, flip*, ...]
- Source:
- See:
-
IntToFix(v)
-
Allegro's itofix.
Parameters:
Name Type Description v
Integer Number to be converted (between 32767 and -32767)
- Source:
Returns:
- Type
- Fixed
-
FloatToFix(v)
-
Allegro's ftofix.
Parameters:
Name Type Description v
Number Number to be converted (between 32767 and -32767)
- Source:
Returns:
- Type
- Fixed
-
FixToInt(v)
-
Allegro's fixtoi.
Parameters:
Name Type Description v
Fixed - Source:
Returns:
Regular number
- Type
- Integer
-
FixToFloat(v)
-
Allegro's fixtof.
Parameters:
Name Type Description v
Fixed - Source:
Returns:
Regular number
- Type
- Number
-
LoadSample(filename)
-
Allegro's load_sample. Loads a digital sample from a sound file.
Returns null on any failure.Parameters:
Name Type Description filename
String - Source:
Returns:
Digital sample object, contains bits, freq, len, and stereo integer valued properties
- Type
- Sample
-
SaveSample(filename, sample)
-
Allegro's save_sample. Saves a digital sample to a sound file.
Parameters:
Name Type Description filename
String sample
Sample Sample
- Source:
-
CreateSample(bits, stereo, freq, len)
-
Allegro's create_sample. Creates a silent digital sample with specified parameters, useful for procedural sfx.
Returns null on any failure.Parameters:
Name Type Description bits
Integer 8 or 16
stereo
Integer 0 for mono, non-zero for stereo
freq
Integer Frequency in hertz
len
Integer Number of samples
- Source:
Returns:
A silent sample
- Type
- Sample
-
PlaySample(sample, vol, pan, freq, loop)
-
Allegro's play_sample. To play audio samples.
A word of warning: if the given sample goes out of scope while it is playing, the finalizer will stop it before destroying it. So keep all playing samples somewhere.Parameters:
Name Type Description sample
Sample Sample
vol
Integer Volume, 0 to 255
pan
Integer Pan, 0 left to 255 right
freq
Integer Relative frequency, where 1000 is the recorded frequency, and 2000 plays at double speed
loop
Boolean If non-zero, will repeat the sample until StopSample is called
- Source:
Returns:
Returns the voice number that was allocated for the sample or negative if no voices were available.
- Type
- Integer
-
StopSample(sample)
-
Allegro's stop_sample.
"Stop a sample from playing, which is required if you have set a sample going in looped mode. If there are several copies of the sample playing, it will stop them all."Parameters:
Name Type Description sample
Sample - Source:
-
AdjustSample(sample, vol, pan, freq, loop)
-
Allegro's adjust_sample.
Alter a playing sample's parameters. Useful for e.g. engine sounds.Parameters:
Name Type Description sample
Sample Sample
vol
Integer Volume, 0 to 255
pan
Integer Pan, 0 left to 255 right
freq
Integer Relative frequency, where 1000 is the recorded frequency, and 2000 plays at double speed
loop
Boolean If non-zero, will repeat the sample until StopSample is called
- Source:
-
GetSampleData(sample)
-
Used to get the raw audio data.
Modifying the returned buffer will have no value unless you call SetSampleData, as it is a copy rather than a pointer of the internal buffer.Parameters:
Name Type Description sample
Sample Sample to get the raw data from
- Source:
Returns:
Array of samples in unsigned 16-bit format
- Type
- Uint16Array
-
SetSampleData(sample, buf)
-
Used to put raw audio data into an usable sample, for procedural audio or otherwise.
Copies the passed samples into the internal buffer.Parameters:
Name Type Description sample
Sample Sample whose data to be set
buf
Uint16Array Array of samples in unsigned 16-bit format
- Source:
-
SetSampleParams(sample, params)
-
Provides access to sample priority and looping points.
Parameters:
Name Type Description sample
Sample Sample whose params to be set
params
Object Properties
Name Type Argument Description priority
Integer <optional>
"The priority is a value from 0 to 255 (by default set to 128) and controls how hardware voices on the sound card are allocated if you attempt to play more than the driver can handle. This may be used to ensure that the less important sounds are cut off while the important ones are preserved."
loop_start
Integer <optional>
"The variables loop_start and loop_end specify the loop position in sample units, and are set by default to the start and end of the sample."
loop_end
Integer <optional>
-
- Source:
-
GetSampleParams(sample)
-
Provides access to sample priority and looping points.
Parameters:
Name Type Description sample
Sample Sample to get params from
- Source:
- See:
Returns:
Object as described in SetSampleData
- Type
- Object
-
LoadMIDI(filename)
-
Allegro's load_midi. Loads .mid files.
Parameters:
Name Type Description filename
String - Source:
Returns:
Object as described in SetSampleData
- Type
- MIDI
-
GetMIDILength(midi)
-
Allegro's get_midi_length. Will also stop any currently playing MIDI. midi_pos and midi_time will also be set.
Parameters:
Name Type Description midi
MIDI - Source:
Returns:
Length of the song in seconds.
- Type
- Integer
-
PauseMIDI()
-
Allegro's pause_midi. Pauses the MIDI player. See ResumeMIDI.
- Source:
-
ResumeMIDI()
-
Allegro's resume_midi. Pauses the MIDI player. See PauseMIDI.
- Source:
-
StopMIDI()
-
Allegro's stop_midi. Stop the MIDI player.
- Source:
-
SeekMIDI(pos)
-
Allegro's midi_seek. Seeks to the given position in the playing song.
Parameters:
Name Type Description pos
Integer Position in beats (not seconds!)
- Source:
-
PlayMIDI(midi, loop)
-
Allegro's play_midi. Starts playing a song.
The given MIDI is copied into the currentMIDI global variable, to avoid finalization.Parameters:
Name Type Description midi
MIDI loop
Boolean If set, continuously loop the song.
- Source:
-
PlayLoopedMIDI(midi, loop_start, loop_end)
-
Allegro's play_looped_midi. Starts playing a song and loops at the specified points.
The given MIDI is copied into the currentMIDI global variable, to avoid finalization.Parameters:
Name Type Description midi
MIDI loop_start
Integer Position in beats (not seconds!)
loop_end
Integer Position in beats (not seconds!)
- Source:
-
SetMIDILoop(loop_start, loop_end)
-
Sets the looping points, the same as PlayLoopedMIDI
Parameters:
Name Type Description loop_start
Integer Position in beats (not seconds!)
loop_end
Integer Position in beats (not seconds!)
- Source:
-
GetMIDIPos()
-
Allegro's midi_pos. Current position in beats of the song being played.
- Source:
Returns:
Position of the song in seconds.
- Type
- Integer
-
GetMIDITime()
-
Allegro's midi_time. Current position in seconds of the song being played.
- Source:
Returns:
Position of the song in seconds.
- Type
- Integer
-
MIDIOut(data)
-
Allegro's midi_out. Direct output of MIDI commands, check some MIDI specs to use.
The first call may need to load MIDI patches, taking some time.Parameters:
Name Type Description data
Uint8Array Series of MIDI commands
- Source:
-
DrawTileLayer(bmp, map, tileset, first, col, row, numCols, numRows, x, y)
-
A tile map drawing routine. Tiles not in the tileset (tile < first or tile > tileset.numberOfFrames) are ignored.
Parameters:
Name Type Description bmp
Bitmap map
Object Properties
Name Type Description data
Uint16Array Tile IDs stored sequentially from left to right and then top to bottom
width
Integer Number of map columns
height
Integer Number of map rows
tileset
SpriteSheet Each frame will be mapped into one tile
first
Integer First tile ID in the tileset
col
Integer First column in the map view
row
Integer First row in the map view
numCols
Integer Number of columns in the map view
numRows
Integer Number of rows in the map view
x
Integer Coordinate in bmp
y
Integer Coordinate in bmp
- Source:
-
SetPrimitiveDrawingMode(mode)
-
Allegro's drawing_mode. Sets the drawing mode affecting only the geometric primitive drawing routines like putpixel, lines, rectangles, circles, floodfill, etc, not the text output, blitting, sprite, etc. drawing functions.
Parameters:
Name Type Description mode
Integer 0 for solid (default mode), 1 for blended (transparency, lighting and other effects)
- Source:
-
SetColorMap(cm)
-
Sets the color map used by transparency and lighting effects in 8-bit color mode. Allegro's color_map.
Get a color map from CreateTransTable, CreateLightTable or CreateColorTable.Parameters:
Name Type Description cm
ColorMap - Source:
-
CreateLightTable(pal, r, g, b)
-
Allegro's create_light_table. Creates a color map for lighting effects in 8-bit color mode.
When combining the colors c1 and c2 with this table, c1 is treated as a light level from 0-255. At light level 255 the table will output color c2 unchanged, at light level 0 it will output the r, g, b value you specify to this function, and at intermediate light levels it will output a color somewhere between the two extremes. The r, g, and b values are in the range 0-63.
Parameters:
Name Type Description pal
Palette r
Integer g
Integer b
Integer - Source:
Returns:
- Type
- ColorMap
-
CreateTransTable(pal, r, g, b)
-
Allegro's create_trans_table. Creates a color map for transparency effects in 8-bit color mode.
When combining the colors c1 and c2 with this table, the result will be a color somewhere between the two. The r, g, and b parameters specify the solidity of each color component, ranging from 0 (totally transparent) to 255 (totally solid). For 50% solidity, pass 128. This function treats source color #0 as a special case, leaving the destination unchanged whenever a zero source pixel is encountered, so that masked sprites will draw correctly.
Parameters:
Name Type Description pal
Palette r
Integer g
Integer b
Integer - Source:
Returns:
- Type
- ColorMap
-
CreateColorTable(pal, blendFunc)
-
Allegro's create_color_table. Creates a color map for customised effects in 8-bit color mode.
Will stop on the first error encountered.Parameters:
Name Type Description pal
Palette blendFunc
function A (palette, color_index1, color_index2)->resulting_rgb_color function
- Source:
Returns:
- Type
- ColorMap
-
SetTruecolorBlender(r, g, b, a)
-
Allegro's set_trans_blender. Selects the default true color blending routine, used for effects in non-8-bit color modes.
When a translucent drawing function is called, the alpha parameter set by this routine is used to select one of the blenders from the table, and that function is then called to blend each pixel with the existing destination color (ie. the alpha parameter controls the solidity of the drawing, from 0 to 255). When a lit sprite drawing function is called, the alpha value passed to this routine is ignored, and instead the color passed to the sprite function is used to select an alpha level. The blender routine will then be used to interpolate between the sprite color and the RGB value that was passed to this function (ranging 0-255).
Parameters:
Name Type Description r
Integer g
Integer b
Integer a
Integer Alpha
- Source:
-
LoadDLL(filename)
-
Loads a dynamically-loaded library.
Those files have .dll extension on Windows, .so on Linux and .dxe on MS-DOS.
If the DLL has a function "void TapegroInit(void *funcptrs, char funcnames, void *duk_ctx)" it will be automatically called, dukfuncnames is comma separated.Parameters:
Name Type Description filename
String Note that the OS-appropriate extension is automatically appended
- Source:
Returns:
- Type
- DLL
-
GetDLLFunction(dll, funcname, nargs, numtype)
-
Returns a wrapper around a function call to a function in the given dynamically-loaded library.
Function arguments will all be translated as 32-bit integer values.
If an argument is a number, it will be converted to either an int32 or a float32.
Pointers, buffers, strings and objects (@Bitmap, @MIDI, etc.) will be passed as void *.
The function is thus assumed to have type "int func(int i1, int i2, ..., int in);"Parameters:
Name Type Description dll
DLL funcname
String nargs
Integer Number of arguments (max 13)
numtype
Boolean If true, number arguments are treated as integers, otherwise as floats
- Source:
Returns:
- Type
- function
-
GetDataBitmap(objname)
-
Fetches a bitmap from the datafile.
Returns null on failures such as datafile object not found.Parameters:
Name Type Description objname
String - Source:
Returns:
- Type
- Bitmap
-
GetDataFont(objname)
-
Fetches a font from the datafile.
Returns null on failures such as datafile object not found.Parameters:
Name Type Description objname
String - Source:
Returns:
- Type
- Font
-
GetDataMIDI(objname)
-
Fetches a MIDI from the datafile.
Returns null on failures such as datafile object not found.Parameters:
Name Type Description objname
String - Source:
Returns:
- Type
- MIDI
-
GetDataSample(objname)
-
Fetches a sample from the datafile.
Returns null on failures such as datafile object not found.Parameters:
Name Type Description objname
String - Source:
Returns:
- Type
- Sample
-
GetDataString(objname)
-
Fetches a string from the datafile.
Returns null on failures such as datafile object not found.Parameters:
Name Type Description objname
String - Source:
Returns:
- Type
- String
-
GetDataBuffer(objname)
-
Fetches a buffer from the datafile.
Returns null on failures such as datafile object not found.Parameters:
Name Type Description objname
String - Source:
Returns:
- Type
- Buffer
-
GifCapStart(filename, params)
-
Starts capturing a GIF to a file.
Returns null on failures such as failure to open the file for writing.Parameters:
Name Type Description filename
String params
Object Properties
Name Type Argument Description width
Integer <optional>
height
Integer <optional>
repeat
Integer <optional>
0 loop forever, 1 play once and don't repeat, 2 repeat once, 3 repeat twice and so on
numColors
Integer <optional>
palette size 2 to 256, 256 won't allow delta frames (causing huge animated gifs)
fps
Integer <optional>
dither
Integer <optional>
0 no dither, 1 floyd-steinberg error diffusion dithering
- Source:
Returns:
- Type
- Pointer
-
GifCapFrame(gifcap, bmp)
-
Writes one frame to a GIF file.
Parameters:
Name Type Description gifcap
Pointer bmp
Bitmap - Source:
-
GifCapEnd(gifcap)
-
Finishes a GIF capture.
Parameters:
Name Type Description gifcap
Pointer - Source:
-
DrawGifFrame(bmp, gif, frame)
-
Draws a single frame from a gif. To play an animation frames must be drawn sequentially due to delta encoding.
Parameters:
Name Type Description bmp
Bitmap Destination
gif
Buffer A buffer containing a gif file, e.g. from {@ReadFile}
frame
Integer - Source:
-
GetGifDelays(gif)
-
Retrieves an array mapping frame index to delay, in centiseconds, to the following frame, for a gif.
Parameters:
Name Type Description gif
Buffer A buffer containing a gif file, e.g. from {@ReadFile}
- Source:
Returns:
- Type
- Array
Type Definitions
-
Bitmap
-
Allegro's BITMAP *. The target of all drawing routines.
Type:
- Object
- Source:
Properties:
Name Type Description w
Integer width
h
Integer width
ptr
Pointer Internal, so don't mess with it
parent
Bitmap Parent bitmap, if this is a subbitmap
-
Font
-
Allegro's FONT *. Used for writing text into the screen and other bitmaps.
Type:
- Object
- Source:
Properties:
Name Type Description ptr
Pointer Internal, so don't mess with it
-
Sample
-
Allegro's SAMPLE *. Digital audio samples, most often used for sound effects.
Type:
- Object
- Source:
Properties:
Name Type Description bits
Integer 8 or 16
stereo
Integer 0 mono, otherwise stereo
freq
Integer in Hz
len
Integer Number of samples
ptr
Pointer Internal, so don't mess with it
-
MIDI
-
Allegro's MIDI *. For playing MIDI music, which is usually small in stored size.
Type:
- Object
- Source:
Properties:
Name Type Description ptr
Pointer Internal, so don't mess with it
-
ColorMap
-
Allegro's COLOR_MAP *. Used for transparency and lighting effects in 8-bit color modes.
Type:
- Object
- Source:
Properties:
Name Type Description ptr
Pointer Internal, so don't mess with it
-
DLL
-
Handle for a dynamically-loaded library. Used to extend Tapegro functionality.
Type:
- Object
- Source:
Properties:
Name Type Description ptr
Pointer Internal, so don't mess with it
-
Palette
-
Allegro's PALETTE. Just a plain DukTape buffer. Note that while we'd expect 256 3 byte groups for RGB, each entry has a 4th padding byte, so this is actually 1024 bytes long.
Type:
- Buffer
- Source:
-
SpriteSheet
-
A sprite sheet structured type.
Type:
- Object
- Source:
Properties:
Name Type Description numberOfFrames
Integer width
Integer Of one frame, not of the bitmap
height
Integer Of one frame, not of the bitmap
bitmap
Bitmap Bitmap containing the sprite's frames
ptr
Pointer Internal, so don't mess with it
-
Fixed
-
Allegro's fixed.
Allegro uses fixed point arithmetics for certain operations, including drawing rotated or scaled images.Fixed point numbers can be assigned, compared, added, subtracted, negated and shifted (for multiplying or dividing by powers of two) using the normal integer operators, but you should take care to use the appropriate conversion routines when mixing fixed point with integer or floating point values.
Type:
- Integer
- Source:
- See: