Project Outline
 
gbox
addAudio(id, filename, def)
addBundle(call)
addFont(data)
addImage(id, filename)
addObject(data)
addScript(call)
blit(tox, image, data)
blitAll(tox, image, data)
blitClear(image, data)
blitFade(tox, data)
blitRect(tox, data)
blitText(tox, data)
blitTile(tox, data)
blitTilemap(tox, data)
centerCamera(data, viewdata)
collides(o1, o2, t)
createCanvas(id, data)
dataLoad(k, a)
dataSave(k, v, d)
getObject(group, id)
go()
hitAudio(a, data)
log()
pixelcollides(o1, o2, t)
playAudio(a, data)
readBundleData(pack, call)
setCameraX(x, viewdata)
setCameraY(y, viewdata)
setZindex(th, z)
stopAudio(a, permissive)
trashGroup(group)
 
help
asciiArtToMap(map, tra)
copyModel(data, model)
createModel(obj, attrs)
decideFrame(cnt, anim)
decideFrameOnce(cnt, anim)
framestotime(frames)
getArrayIndexed(a, value, field)
getTileInMap(x, y, map, ifout, mapid)
isLastFrameOnce(cnt, anim)
isSquished(th, by)
limit(v, min, max)
mergeWithModel(data, model)
multiplier(v, mul)
postpad(str, len, pad)
prepad(str, len, pad)
random(min, range)
seq(st, ed, skip)
setTileInMap(ctx, map, x, y, tile, The)
upAndDown(counter, max)
xPixelToTile(map, x, gap)
xPixelToTileX(map, x, gap)
yPixelToTile(map, y, gap)
yPixelToTileY(map, y, gap)
controlKeys(th, keys)
fireBullet(gr, id, data)
generateEnemy(gr, id, data, model)
generateScroller(gr, id, data)
hitByBullet(th, by)
initialize(th, data)
spawn(th, data)
after(th, id, frames)
every(th, id, frames)
randomly(th, id, data)
real(th, id, data)
 
tool
makecels(data)
callInColliding(th, data)
collides(fr, to, t)
controlKeys(th, keys)
fireBullet(gr, id, data)
floorCollision(th, data)
getAheadPixel(th, data)
initialize(th, data)
makedoor(gr, id, map, data)
pixelcollides(fr, to, t)
setStaticSpeed(th, speed)
spawn(
  • y {Integer}: (required)The object's y position.">th, data)
  • tileCollision(th, map, tilemap, defaulttile, data)
    wander(th, map, tilemap, defaulttile, data)
    addAngle(a, add)
    getAngle(p1, p2, transl)
    getDistance(p1, p2)
    translate(p1, a, d)
    translateX(x1, a, d)
    translateY(y1, a, d)
    «
    Akihabara Framework

    Namespace help

    Help module provides some Javascript-specific functions, such object copying, randomizing functions, string/array handlers and the akihabaraInit function.

    Defined in: help.js.

    Method Summary
    akihabaraInit(data) This provides a number of configurations: fps, display zoom, dynamic frameskip, force touch parameters, etc. Many of these settings can be set manually by passing an object with the parameters defined, or via URL parameters.
    asciiArtToMap(map, tra) Takes an ascii-art-style array of characters and converts it to an Akihabara-compatible map format.
    cloneObject(model) Creates a duplicate of an existing set of parameters.
    copyModel(data, model) Merges two sets of parameters together overwriting any existing parameters. This merges model->data, and if data and model share parameters, data's are overwritten by model's.
    createModel(obj, attrs) Creates a subset of an existing set of parameters.
    decideFrame(cnt, anim) Determines which frame of a given animation to display. Will loop an animation.
    decideFrameOnce(cnt, anim) Determines which frame of a given animation to display. Will remain on the last frame when the animation has played once.
    finalizeTilemap(map) Calculates and sets the width and height (map.h, map.w) and half-width and half-height (map.hh, map.hw) of a map object.
    framestotime(frames) Converts a quantity of frames into a timestamp formatted "mm:ss:cs" (minutes, seconds, centiseconds). Calculated using the current frames per second.
    getArrayCapped(a, id) Returns the Nth element in an array. If the array is shorter than N, it returns the last element of the array.
    getArrayIndexed(a, value, field)
    getDeviceConfig() Automatically configures a bunch of settings depending on the web browser and device that is viewing the game. Mostly sets the maximum number of audio channels and touch settings.
    getTileInMap(x, y, map, ifout, mapid) Given x,y coordinates and map information, this returns the tile at a given point.
    geturlparameter(name) Reads the value of a query parameter from the URL of the web page.
    goToZero(v) Subtracts or adds 1 to a value, always converging to zero. For example, passing -3 yields -2, 5 yields 4, etc.
    isDefined(A) Tests whether an object contains a given parameter.
    isLastFrameOnce(cnt, anim) Returns whether the animation was fully played at least once with decideFrame or fully with decideFrameOnce.
    0 means you're falling onto something else.">isSquished(th, by) Tests to see if an object is being "jumped on" by another object. Only works for platformers, since it assumes accy>0 means you're falling onto something else.
    limit(v, min, max) Limits a number to a certain range. If the number is below the minimum, the minimum is returned.
    mergeWithModel(data, model) Merges two sets of parameters together without overwriting existing parameters. This merges from model to data, and if data and model share parameters, data's values remain intact.
    multiplier(v, mul) Multiplies two numbers together, returning the result, unless the first parameter is less than 2, in which case it returns 1.
    objToStr(Any) Writes the contents of an object to a string. Useful for debugging.
    postpad(str, len, pad) Postpends a string with repeated instances of another string until it the result is greater than or equal to a desired length.
    prepad(str, len, pad) Prepends a string with repeated instances of another string until it the result is greater than or equal to a desired length.
    random(min, range) Generates uniformly distributed random integers between min and min+range, non-inclusive. So help.random(0,2) will only return 0 and 1, etc.
    seq(st, ed, skip) Generates numbers from st to ed, along with a skip value.
    setTileInMap(ctx, map, x, y, tile, The) Sets a tile in the map and draws it. Does not return anything.
    upAndDown(counter, max) Given an incrementing value each step, this will return a value increasing from 0 until max/2, at which point it will decrement to 0, then go back up to max/2, in an endless cycle.
    xPixelToTile(map, x, gap) Converts an x-coordinate of a pixel to the x-coordinate of the tile column it's in. This effectively "snaps" an x coordinate to a tile edge.
    xPixelToTileX(map, x, gap) Converts an x-coordinate of a pixel to its corresponding tile x-coordinate.
    yPixelToTile(map, y, gap) Converts a y-coordinate of a pixel to the y-coordinate of the tile row it's in. This effectively "snaps" a y coordinate to a tile edge.
    yPixelToTileY(map, y, gap) Converts a y-coordinate of a pixel to its corresponding tile y-coordinate.
    Method Detail
    help.akihabaraInit(data)
    This provides a number of configurations: fps, display zoom, dynamic frameskip, force touch parameters, etc. Many of these settings can be set manually by passing an object with the parameters defined, or via URL parameters.
    
    										
    									
    Parameters:
    {Object} data An optional object containing parameters you wish to set. Works for data.zoom, data.splash, data.width, data.height, data.title, data.fps, and data.padmode.
    help.asciiArtToMap(map, tra)
    Takes an ascii-art-style array of characters and converts it to an Akihabara-compatible map format.
    
    										
    									
    Parameters:
    {Array} map An array of characters representing a map.
    {Array} tra A translation array. This is an array of arrays, formatted like [ [null, char1], [0, char2], [1, char3] ]. There must at least be a null entry, followed by one numerical entry for each tile type you want to render, corresponding to the unique characters in the map array. The null entry maps a character to empty space.
    Returns:
    A map array formatted such that it can be attached to a map object.
    help.cloneObject(model)
    Creates a duplicate of an existing set of parameters.
    data = {a: 1, b: 2, c: "three"};
    newdata = help.cloneObject(data);
    newdata; // => {a: 1, b: 2, c: "three"}
    Parameters:
    {Object} model An object containing a set of parameters.
    Returns:
    A new object, equivalent to 'model'.
    help.copyModel(data, model)
    Merges two sets of parameters together overwriting any existing parameters. This merges model->data, and if data and model share parameters, data's are overwritten by model's.
    dst = {a: 1, b: 2, c: "three"};
    src = {c: "three", d: "four"};
    merged = help.mergeWithModel(dst,src);
    merged; // => {a: 1, b: 2, c: "three", d: "four"}
    Parameters:
    {Object} data An object containing a set of parameters, the destination of the merge.
    {Object} model An object containing a set of parameters, the source of the merge.
    Returns:
    A merged model where the values of 'model' take precedence over those of 'data'. The 'data' object is returned and will be an exact copy of 'model', plus any parameters that 'data' had before the merge that 'model' did not.
    help.createModel(obj, attrs)
    Creates a subset of an existing set of parameters.
    data = {a: 1, b: 2, c: "three"};
    newdata = help.createModel(data, ["a", "c"]);
    newdata; // => {a: 1, c: "three"}
    Parameters:
    {Object} obj An object containing a set of parameters, the source of the data.
    {Array} attrs An array of strings, containing the names of parameters you wish to copy.
    Returns:
    A new set of parameters based on the subset specified.
    help.decideFrame(cnt, anim)
    Determines which frame of a given animation to display. Will loop an animation.
    
    										
    									
    Parameters:
    {Integer} cnt A global frame counter.
    {Object} anim An object with parameters speed (the animation speed) and frames (the array representing the animation sequence).
    Returns:
    The particular animation frame to display during this step.
    help.decideFrameOnce(cnt, anim)
    Determines which frame of a given animation to display. Will remain on the last frame when the animation has played once.
    
    										
    									
    Parameters:
    {Integer} cnt A global frame counter.
    {Object} anim An object with parameters speed (the animation speed) and frames (the array representing the animation sequence).
    Returns:
    The particular animation frame to display during this step.
    help.finalizeTilemap(map)
    Calculates and sets the width and height (map.h, map.w) and half-width and half-height (map.hh, map.hw) of a map object.
    
    										
    									
    Parameters:
    {Object} map A map object, containing a map array and a tileset array.
    Returns:
    A map object with map.w, map.h, map.hh, and map.hw set correctly.
    help.framestotime(frames)
    Converts a quantity of frames into a timestamp formatted "mm:ss:cs" (minutes, seconds, centiseconds). Calculated using the current frames per second.
    // Assuming 25 frames per second, Akihabara's default.
    timestamp = help.framestotime(25);
    timestamp; // => '00:01:00';
    timestamp = help.framestotime(25 * 60);
    timestamp; // => '01:00:00';
    Parameters:
    {Integer} frames A quantity of frames.
    Returns:
    A string containing a timestamp formatted "mm:ss:cs", representing the length of time it would take to render that many frames.
    help.getArrayCapped(a, id)
    Returns the Nth element in an array. If the array is shorter than N, it returns the last element of the array.
    
    										
    									
    Parameters:
    {Array} a An array.
    {Integer} id An index to the array.
    Returns:
    If id > a.length, it returns a[a.length-1]. Otherwise returns a[id].
    help.getArrayIndexed(a, value, field)
    
    										
    									
    Parameters:
    a
    value
    field
    help.getDeviceConfig()
    Automatically configures a bunch of settings depending on the web browser and device that is viewing the game. Mostly sets the maximum number of audio channels and touch settings.
    
    										
    									
    help.getTileInMap(x, y, map, ifout, mapid)
    Given x,y coordinates and map information, this returns the tile at a given point.
    
    										
    									
    Parameters:
    {Integer} x An x-coordinate.
    {Integer} y A y-coordinate.
    {Object} map The map object.
    {Object} ifout An object or value to be returned if the x,y coordinate pair is outside the map.
    {String} mapid The id for the map array within the map object. Default is 'map'.
    Returns:
    An integer representing the value of the tile in the map array at that x,y coordinate. If there is no tile, null is returned.
    help.geturlparameter(name)
    Reads the value of a query parameter from the URL of the web page.
    // If the URL is http://example.com/game.html?lives=3
    player.lives = help.geturlparameter("lives");
    player.lives; // => 3
    Parameters:
    {String} name The name of the URL parameter.
    Returns:
    The value of the URL parameter, as a string.
    help.goToZero(v)
    Subtracts or adds 1 to a value, always converging to zero. For example, passing -3 yields -2, 5 yields 4, etc. Works best with integers.
    
    										
    									
    Parameters:
    {Integer} v A value.
    Returns:
    A value that is one closer to 0 on the number line than v.
    help.isDefined(A)
    Tests whether an object contains a given parameter.
    foo = {a: 1, b: 2};
    help.isDefined(foo.a); // => true
    help.isDefined(foo.c); // => false
    Parameters:
    {Object} A reference to a parameter of an object.
    Returns:
    True if the object contains that parameter, false if it does not.
    help.isLastFrameOnce(cnt, anim)
    Returns whether the animation was fully played at least once with decideFrame or fully with decideFrameOnce.
    
    										
    									
    Parameters:
    {Integer} cnt A global frame counter.
    {Object} anim An object with parameters speed (the animation speed) and frames (the array representing the animation sequence).
    Returns:
    A boolean, true if the animation has been played at least once.
    help.isSquished(th, by)
    Tests to see if an object is being "jumped on" by another object. Only works for platformers, since it assumes accy>0 means you're falling onto something else.
    
    										
    									
    Parameters:
    {Object} th The object that is (possibly) being jumped on.
    {Object} by The object doing the jumping-on.
    Returns:
    True if the two objects are overlapping enough and by.accy>0.
    help.limit(v, min, max)
    Limits a number to a certain range. If the number is below the minimum, the minimum is returned. If the number is above the maximum, the maximum is returned.
    
    										
    									
    Parameters:
    {Float} v A value.
    {Float} min The minimum limit.
    {Float} max The maximum limit.
    Returns:
    A value equal to v if minmax.
    help.mergeWithModel(data, model)
    Merges two sets of parameters together without overwriting existing parameters. This merges from model to data, and if data and model share parameters, data's values remain intact.
    dst = {a: 1, b: 2, c: "three"};
    src = {c: "three", d: "four"};
    merged = help.mergeWithModel(dst,src);
    merged; // => {a: 1, b: 2, c: 3, d: "four"};
    Parameters:
    {Object} data An object containing a set of parameters, the destination of the merge.
    {Object} model An object containing a set of parameters, the source of the merge.
    Returns:
    A merged model where the values of 'data' remain untouched: only new parameters and values from 'model' make it in.
    help.multiplier(v, mul)
    Multiplies two numbers together, returning the result, unless the first parameter is less than 2, in which case it returns 1.
    
    										
    									
    Parameters:
    {Float} v First value.
    {Float} mul Second value.
    Returns:
    An integer, v*mul, unless v<2 in which case it returns 1.
    help.objToStr(Any)
    Writes the contents of an object to a string. Useful for debugging.
    
    										
    									
    Parameters:
    {Object} Any object.
    Returns:
    A string containing all the contents of an object. If the object contains functions, the string will contain the code for those functions.
    help.postpad(str, len, pad)
    Postpends a string with repeated instances of another string until it the result is greater than or equal to a desired length.
    
    										
    									
    Parameters:
    {String} str The string you wish to modify.
    {Integer} len The desired length of your resultant string.
    {String} pad The string you wish to postpend to str.
    Returns:
    A string whose length is no greater than len+pad.length, with pad postpending str repeatedly.
    help.prepad(str, len, pad)
    Prepends a string with repeated instances of another string until it the result is greater than or equal to a desired length.
    
    										
    									
    Parameters:
    {String} str The string you wish to modify.
    {Integer} len The desired length of your resultant string.
    {String} pad The string you wish to prepend to str.
    Returns:
    A string whose length is no greater than len+pad.length, with pad prepending str repeatedly.
    help.random(min, range)
    Generates uniformly distributed random integers between min and min+range, non-inclusive. So help.random(0,2) will only return 0 and 1, etc.
    
    										
    									
    Parameters:
    {Integer} min The minimum random value to be returned by the function.
    {Integer} range The number of different values returned by the function.
    Returns:
    An integer between min (includive) and min+range (noninclusive).
    help.seq(st, ed, skip)
    Generates numbers from st to ed, along with a skip value.
    
    										
    									
    Parameters:
    {Integer} st Starting number.
    {Integer} ed Ending number.
    {Integer} skip Number to increment by.
    Returns:
    An array containing the set of numbers from st to ed, incrementing by skip.
    help.setTileInMap(ctx, map, x, y, tile, The)
    Sets a tile in the map and draws it. Does not return anything.
    // Remove the second tile to the right and down from the upper left corner of the tile map. Assumes our map canvas is called 'map_canvas'.
    help.setTileInMap(gbox.getCanvasContext("map_canvas"),map,1,1,null,"map");
    Parameters:
    {Object} ctx The canvas context for the map. Accessed via gbox.getCanvasContext("canvasname")
    {Object} map The game map object.
    {Integer} x The index of the tile column within the map array -- so a 1 would mean the second column of tiles.
    {Integer} y The index of the tile row within the map array -- so a 1 would mean the second row of tiles.
    {Integer} tile The integer representing the new tile you wish to draw. This is its index within the tileset; a null value will erase whatever tile is present.
    {String} The ID of the map. Defaults to 'map'.
    help.upAndDown(counter, max)
    Given an incrementing value each step, this will return a value increasing from 0 until max/2, at which point it will decrement to 0, then go back up to max/2, in an endless cycle.
    
    										
    									
    Parameters:
    {Integer} counter A counter.
    {Integer} max This determines the period of the function -- assuming counter is incrementing by one, a complete back-and-forth will take 'max' steps.
    Returns:
    An integer.
    help.xPixelToTile(map, x, gap)
    Converts an x-coordinate of a pixel to the x-coordinate of the tile column it's in. This effectively "snaps" an x coordinate to a tile edge.
    
    										
    									
    Parameters:
    {Object} map A map object, containing a map array and a tileset array.
    {Integer} x An x-coordinate.
    {Integer} gap Number of pixels gap in tilemap. Default is 0.
    Returns:
    The x-coordinate in pixels of the tile column.
    help.xPixelToTileX(map, x, gap)
    Converts an x-coordinate of a pixel to its corresponding tile x-coordinate.
    
    										
    									
    Parameters:
    {Object} map A map object, containing a map array and a tileset array.
    {Integer} x An x-coordinate.
    {Integer} gap (Not used.)
    Returns:
    A map object with map.w, map.h, map.hh, and map.hw set correctly.
    help.yPixelToTile(map, y, gap)
    Converts a y-coordinate of a pixel to the y-coordinate of the tile row it's in. This effectively "snaps" a y coordinate to a tile edge.
    
    										
    									
    Parameters:
    {Object} map A map object, containing a map array and a tileset array.
    {Integer} y A y-coordinate.
    {Integer} gap Number of pixels gap in tilemap. Default is 0.
    Returns:
    The y-coordinate in pixels of the tile row.
    help.yPixelToTileY(map, y, gap)
    Converts a y-coordinate of a pixel to its corresponding tile y-coordinate.
    
    										
    									
    Parameters:
    {Object} map A map object, containing a map array and a tileset array.
    {Integer} y A y-coordinate.
    {Integer} gap (Not used.)
    Returns:
    A map object with map.w, map.h, map.hh, and map.hw set correctly.
    Documentation generated by JsDoc Toolkit 2.3.2 on Wed Aug 18 2010 15:59:18 GMT-0400 (EDT)