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 scancodeInteger - 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 idInteger 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 bitmapBitmap xInteger yInteger ang1Fixed ang2Fixed rInteger - Source:
-
Circle(bitmap, x, y, radius, color)
-
Allegro's circle.
Parameters:
Name Type Description bitmapBitmap xInteger yInteger radiusInteger colorInteger - Source:
-
CircleFill(bitmap, x, y, radius, color)
-
Allegro's circlefill. Like Circle, but with the insides filled in.
Parameters:
Name Type Description bitmapBitmap xInteger yInteger radiusInteger colorInteger - Source:
-
ClearToColor(bitmap, colour)
-
Allegro's clear_to_color. Fills the passed bitmap with the specified colour.
Parameters:
Name Type Description bitmapBitmap colourInteger - Source:
-
Ellipse(bitmap, x, y, radiusX, radiusY, color)
-
Allegro's ellipse.
Parameters:
Name Type Description bitmapBitmap xInteger yInteger radiusXInteger radiusYInteger colorInteger - Source:
-
EllipseFill(bitmap, x, y, radiusX, radiusY, color)
-
Allegro's circlefill. Like Ellipse, but with the insides filled in.
Parameters:
Name Type Description bitmapBitmap xInteger yInteger radiusXInteger radiusYInteger colorInteger - Source:
-
FloodFill(bitmap, x, y, colour)
-
Allegro's floodfill.
Parameters:
Name Type Description bitmapBitmap xInteger yInteger colourInteger - Source:
-
HLine(bitmap, x1, y, x2, colour)
-
Allegro's hline.
Parameters:
Name Type Description bitmapBitmap x1Integer yInteger x2Integer colourInteger - Source:
-
Line(bitmap, x1, y1, x2, y2, colour)
-
Allegro's line.
Parameters:
Name Type Description bitmapBitmap x1Integer y1Integer x2Integer y2Integer colourInteger - Source:
-
PutPixel(bitmap, x, y, colour)
-
Allegro's putpixel.
Parameters:
Name Type Description bitmapBitmap xInteger yInteger colourInteger - Source:
-
Rect(bitmap, x1, y1, x2, y2, colour)
-
Allegro's rect.
Parameters:
Name Type Description bitmapBitmap x1Integer y1Integer x2Integer y2Integer colourInteger - Source:
-
RectFill(bitmap, x1, y1, x2, y2, colour)
-
Allegro's rectfill. Like Rect, but with the insides filled in.
Parameters:
Name Type Description bitmapBitmap x1Integer y1Integer x2Integer y2Integer colourInteger - 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 bitmapBitmap x1Integer y1Integer x2Integer y2Integer x3Integer y3Integer colourInteger - Source:
-
VLine(bitmap, x, y1, y2, colour)
-
Allegro's vline.
Parameters:
Name Type Description bitmapBitmap xInteger y1Integer y2Integer colourInteger - Source:
-
GetPixel(bitmap, x, y)
-
Allegro's getpixel.
Parameters:
Name Type Description bitmapBitmap xInteger yInteger - 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 bitmapBitmap rleBoolean Whether RLE is used
bufInt32Array 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 widthInteger heightInteger - 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 coldepthInteger widthInteger heightInteger - 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 bmpBitmap xInteger 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
yInteger As above, including alignment issue
wInteger hInteger - 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 filenameString - 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 filenameString bitmapBitmap - 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 bmpBitmap Bitmap drawed on
sprBitmap Bitmap drawed
XInteger YInteger - 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 bitmapBitmap Bitmap drawed on
sprBitmap Bitmap drawed
transformsInteger Binary flags for transforms used (SPRITE_FLIP, SPRITE_ROTATE, SPRITE_SCALE)
angleFixed <optional>
256.0 is a full rotation
scaleFixed <optional>
2.0 is double the size
flipInteger <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 bmpBitmap Bitmap drawed on
sprBitmap Bitmap drawed
XInteger YInteger blenderInteger 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 filenameString - 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 palPalette - 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 rInteger gInteger bInteger - Source:
-
ReadFile(filename)
-
Reads a binary file and returns its contents.
Returns null on any failures.Parameters:
Name Type Description filenameString - 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 filenameString - 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 filenameString bufBuffer 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 filenameString strString 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 filenameString - 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 filenameString - 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 wildcardString - 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 configsObject Will be modified to contain the values read. Example:
Properties
Name Type Argument Default Description a_valueNumber <optional>
5 Reads a floating point value from the root of the config file, with default value 5.0
a_sectionObject A [section] in the config file
Properties
Name Type Argument Default Description another_valueString <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 configsObject Will be written to config file. Example:
Properties
Name Type Argument Default Description a_valueNumber <optional>
5 Writes "a_value = 5.0" (in the root of the config file i.e. the top with no section above)
a_sectionObject Writes [a_section] in the config file
Properties
Name Type Argument Default Description anoter_valueString <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 bmpBitmap Bitmap written on
textString Text
xInteger X
yInteger Y
fgInteger 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 allignInteger 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 bgInteger 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 filenameString - 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 fontFont - 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 srcBitmap Source bitmap
destBitmap Destination bitmap
sxInteger Source X
syInteger Source Y
dxInteger Destination X
dyInteger Destination Y
wInteger Width of area copied
hInteger 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 srcBitmap Source bitmap
destBitmap Destination bitmap
sxInteger Source X
syInteger Source Y
swInteger Source width
shInteger Source height
dxInteger Destination X
dyInteger Destination Y
dwInteger Destination width
dhInteger 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 srcBitmap Source bitmap
destBitmap Destination bitmap
sxInteger Source X
syInteger Source Y
dxInteger Destination X
dyInteger Destination Y
wInteger Width of area copied
hInteger 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 srcBitmap Source bitmap
destBitmap Destination bitmap
sxInteger Source X
syInteger Source Y
swInteger Source width
shInteger Source height
dxInteger Destination X
dyInteger Destination Y
dwInteger Destination width
dhInteger 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 bitmapBitmap Bitmap containing the sprite's frames
wInteger Width of one frame
hInteger 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 bitmapBitmap Bitmap drawed on
ssSpriteSheet Spritesheet object
xInteger X
yInteger Y
fInteger Frame index
- Source:
-
DrawBlendedSprite(bitmap, ss, x, y, f, blender)
-
An extension of DrawSprite. Does blending just like DrawBlendedBitmap.
Parameters:
Name Type Description bitmapBitmap Bitmap drawed on
ssSpriteSheet Spritesheet object
xInteger X
yInteger Y
fInteger Frame index
blenderInteger 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 bitmapBitmap Bitmap drawed on
ssSpriteSheet Spritesheet object
transformsInteger Binary flags for transforms used (SPRITE_FLIP, SPRITE_ROTATE, SPRITE_SCALE)
XInteger YInteger fInteger Frame index
angleFixed <optional>
256.0 is a full rotation
scaleFixed <optional>
2.0 is double the size
flipsInteger <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 bitmapBitmap Bitmap drawed on
ssSpriteSheet Spritesheet object
modeInteger Either SPRITE_BLEND or binary flags for transforms used (SPRITE_FLIP, SPRITE_ROTATE, SPRITE_SCALE)
bufInt32Array 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 vInteger Number to be converted (between 32767 and -32767)
- Source:
Returns:
- Type
- Fixed
-
FloatToFix(v)
-
Allegro's ftofix.
Parameters:
Name Type Description vNumber Number to be converted (between 32767 and -32767)
- Source:
Returns:
- Type
- Fixed
-
FixToInt(v)
-
Allegro's fixtoi.
Parameters:
Name Type Description vFixed - Source:
Returns:
Regular number
- Type
- Integer
-
FixToFloat(v)
-
Allegro's fixtof.
Parameters:
Name Type Description vFixed - 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 filenameString - 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 filenameString sampleSample 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 bitsInteger 8 or 16
stereoInteger 0 for mono, non-zero for stereo
freqInteger Frequency in hertz
lenInteger 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 sampleSample Sample
volInteger Volume, 0 to 255
panInteger Pan, 0 left to 255 right
freqInteger Relative frequency, where 1000 is the recorded frequency, and 2000 plays at double speed
loopBoolean 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 sampleSample - 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 sampleSample Sample
volInteger Volume, 0 to 255
panInteger Pan, 0 left to 255 right
freqInteger Relative frequency, where 1000 is the recorded frequency, and 2000 plays at double speed
loopBoolean 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 sampleSample 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 sampleSample Sample whose data to be set
bufUint16Array Array of samples in unsigned 16-bit format
- Source:
-
SetSampleParams(sample, params)
-
Provides access to sample priority and looping points.
Parameters:
Name Type Description sampleSample Sample whose params to be set
paramsObject Properties
Name Type Argument Description priorityInteger <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_startInteger <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_endInteger <optional>
-
- Source:
-
GetSampleParams(sample)
-
Provides access to sample priority and looping points.
Parameters:
Name Type Description sampleSample 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 filenameString - 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 midiMIDI - 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 posInteger 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 midiMIDI loopBoolean 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 midiMIDI loop_startInteger Position in beats (not seconds!)
loop_endInteger Position in beats (not seconds!)
- Source:
-
SetMIDILoop(loop_start, loop_end)
-
Sets the looping points, the same as PlayLoopedMIDI
Parameters:
Name Type Description loop_startInteger Position in beats (not seconds!)
loop_endInteger 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 dataUint8Array 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 bmpBitmap mapObject Properties
Name Type Description dataUint16Array Tile IDs stored sequentially from left to right and then top to bottom
widthInteger Number of map columns
heightInteger Number of map rows
tilesetSpriteSheet Each frame will be mapped into one tile
firstInteger First tile ID in the tileset
colInteger First column in the map view
rowInteger First row in the map view
numColsInteger Number of columns in the map view
numRowsInteger Number of rows in the map view
xInteger Coordinate in bmp
yInteger 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 modeInteger 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 cmColorMap - 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 palPalette rInteger gInteger bInteger - 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 palPalette rInteger gInteger bInteger - 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 palPalette blendFuncfunction 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 rInteger gInteger bInteger aInteger 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 filenameString 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 dllDLL funcnameString nargsInteger Number of arguments (max 13)
numtypeBoolean 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 objnameString - 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 objnameString - 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 objnameString - 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 objnameString - 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 objnameString - 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 objnameString - 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 filenameString paramsObject Properties
Name Type Argument Description widthInteger <optional>
heightInteger <optional>
repeatInteger <optional>
0 loop forever, 1 play once and don't repeat, 2 repeat once, 3 repeat twice and so on
numColorsInteger <optional>
palette size 2 to 256, 256 won't allow delta frames (causing huge animated gifs)
fpsInteger <optional>
ditherInteger <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 gifcapPointer bmpBitmap - Source:
-
GifCapEnd(gifcap)
-
Finishes a GIF capture.
Parameters:
Name Type Description gifcapPointer - 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 bmpBitmap Destination
gifBuffer A buffer containing a gif file, e.g. from {@ReadFile}
frameInteger - Source:
-
GetGifDelays(gif)
-
Retrieves an array mapping frame index to delay, in centiseconds, to the following frame, for a gif.
Parameters:
Name Type Description gifBuffer 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 wInteger width
hInteger width
ptrPointer Internal, so don't mess with it
parentBitmap 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 ptrPointer 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 bitsInteger 8 or 16
stereoInteger 0 mono, otherwise stereo
freqInteger in Hz
lenInteger Number of samples
ptrPointer 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 ptrPointer 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 ptrPointer 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 ptrPointer 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 numberOfFramesInteger widthInteger Of one frame, not of the bitmap
heightInteger Of one frame, not of the bitmap
bitmapBitmap Bitmap containing the sprite's frames
ptrPointer 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: