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(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 toys.topview

Top-view RPG specific libraries.

Defined in: toys.js.

Method Summary
applyForces(th) Sets the objects current location to its next location using the getNextX and getNextY methods.
applyGravity(th) This applies acceleration in the Z direction (not nessesarily gravity but whatever the next accerlation on the Z axis is)
callInColliding(th, data)
collides(fr, to, t) Checks if an object checks that both objects are on the same Z plane and if so it calls gbox.collides.
controlKeys(th, keys) This sets and runs the control keys for the game.
fireBullet(gr, id, data)
floorCollision(th, data) This checks if the object's z index is 0 which means it has hit the floor. If this has occured it also plays an impact or bounce noise if one is passed in.
getAheadPixel(th, data)
getNextX(th) Gets the next X position the object is going to move to.
getNextY(th) Gets the next Y position the object is going to move to.
getNextZ(th) Gets the next Z position the object is going to move to.
handleAccellerations(th) Degrades all accelerations on an object by one toward zero.
handleGravity(th) Increases the Z acceleration on the object by one.
initialize(th, data) Initializes the game with the variables needed for topview and whatever else you feed in through data.
makedoor(gr, id, map, data)
pixelcollides(fr, to, t) Checks for pixel collisions with an offset to the X and Y of the colidable using colx and coly.
setFrame(th) This sets which frame the object is going to display based on an agregate word that describes predefined states.
setStaticSpeed(th, speed)
spawn(th, data) Spawns a new object in the topview namespace. This also merges parameters in data into paramaters in th using help.copyModel.
tileCollision(th, map, tilemap, defaulttile, data) Checks if the specified object is colliding with tiles in the map in an area defined by the object's colw and colh variables as well as the tolerance and approximation variables that are passed in through data. Only tiles in the map marked as solid are checked against.
wander(th, map, tilemap, defaulttile, data)
Method Detail
toys.topview.adjustZindex(th)

										
									
Parameters:
th
toys.topview.applyForces(th)
Sets the objects current location to its next location using the getNextX and getNextY methods.

										
									
Parameters:
{Object} th The object being modified.
  • x: the current x position of the object
  • y: the current y position of the object
  • accx: the object's currect acceleration in the x direction
  • accy: the object's currect acceleration in the y direction
  • maxacc: the max accleration the object can have (if either acceleration is greater than this then this value is used instead for that acceleration)
toys.topview.applyGravity(th)
This applies acceleration in the Z direction (not nessesarily gravity but whatever the next accerlation on the Z axis is)

										
									
Parameters:
{Object} th The object being modified.
  • z: the current z position of the object
  • accz: the object's currect acceleration in the z direction
  • maxacc: the max accleration the object can have (if accz is greater than this then this value is used instead)
toys.topview.callInColliding(th, data)

										
									
Parameters:
th
data
toys.topview.collides(fr, to, t)
Checks if an object checks that both objects are on the same Z plane and if so it calls gbox.collides.

										
									
Parameters:
{Object} fr The object which collision is being checked for.
  • x{Integer}: (required)Objects x position
  • y{Integer}: (required)Objects y position
  • z{Integer}: (required)Objects z position
  • colx{Integer}: (required)The dimension of the collision box along the x axis
  • coly{Integer}: (required)The dimension of the collision box along the y axis
  • colh{Integer}: (required)Collision box height
  • colw{Integer}: (required)Collision box width
{Object} to The object that collision is being checked against.
  • x{Integer}: (required)Objects x position
  • y{Integer}: (required)Objects y position
  • z{Integer}: (required)Objects z position
  • colx{Integer}: (required)Collision x
  • coly{Integer}: (required)Collision y
  • colh{Integer}: (required)Collision box height
  • colw{Integer}: (required)Collision box width
{int} t This is the tollerance (or margin for error) on the collide function.
toys.topview.controlKeys(th, keys)
This sets and runs the control keys for the game.

										
									
Parameters:
{Object} th This is the object that is being controlled by the keys (assumed to be the player)
  • accx: the object's currect acceleration in the x direction
  • accy: the object's currect acceleration in the y direction
  • responsive: minimum movement speed
  • staticspeed: turns off acceleration
  • nodiagonals: boolean determining if the object can move along both axis at once.
  • xpushing: a boolean that notes whether the object is pushing against something in the x direction.
  • ypushing: a boolean that notes whether the object is pushing against something in the y direction.
  • controlmaxacc: max acceleration for the object along an axis
  • noreset: checks for the object being allowed to reset its pushing status (?)
{Object} keys These are the control keys being passed in for left, right, up, and down. //incomplete
toys.topview.fireBullet(gr, id, data)

										
									
Parameters:
gr
id
data
toys.topview.floorCollision(th, data)
This checks if the object's z index is 0 which means it has hit the floor. If this has occured it also plays an impact or bounce noise if one is passed in. Note: The area above the floor is in the negative z index space so a value of 1 for z will return that the object has collided with the floor and z will then be set to zero.

										
									
Parameters:
{Object} th The object being checked for collision.
  • touchedfloor{boolean}: This value is not passed in but is created or set in the function. This contains the function's return value.
{Object} data This is used to pass in extra parameters.
toys.topview.getAheadPixel(th, data)

										
									
Parameters:
th
data
toys.topview.getNextX(th)
Gets the next X position the object is going to move to.

										
									
Parameters:
{Object} th The object being checked.
  • x: the current x position of the object
  • accx: the object's currect acceleration in the x direction
  • maxacc: the max accleration the object can have (if accx is greater than this then this value is used instead)
toys.topview.getNextY(th)
Gets the next Y position the object is going to move to.

										
									
Parameters:
{Object} th The object being checked.
  • y: the current y position of the object
  • accy: the object's currect acceleration in the y direction
  • maxacc: the max accleration the object can have (if accy is greater than this then this value is used instead)
toys.topview.getNextZ(th)
Gets the next Z position the object is going to move to.

										
									
Parameters:
{Object} th The object being checked.
  • z: the current z position of the object
  • accz: the object's currect acceleration in the z direction
  • maxacc: the max accleration the object can have (if accz is greater than this then this value is used instead)
toys.topview.handleAccellerations(th)
Degrades all accelerations on an object by one toward zero.

										
									
Parameters:
{Object} th The object being modified.
  • xpushing: a boolean that notes whether the object is pushing against something in the x direction.
  • ypushing: a boolean that notes whether the object is pushing against something in the y direction.
  • accx: the object's currect acceleration in the x direction
  • accy: the object's currect acceleration in the y direction
toys.topview.handleGravity(th)
Increases the Z acceleration on the object by one.

										
									
Parameters:
{Object} th The object being modified.
  • accz: the acceleration on the Z axis
toys.topview.initialize(th, data)
Initializes the game with the variables needed for topview and whatever else you feed in through data.

										
									
Parameters:
{Object} th Passes in the object being initialized.
{Object} data This is used to pass in everything that's being initiliized. If a value is not in Data then a default value is used instead. This can pass in values which do not have a default.
  • x{Integer}: x position of the object. (defaults to 0)
  • y{Integer}: y position of the object. (defaults to 0)
  • z{Integer}: z index of the object. (defaults to 0)
  • accx{Integer}: The starting x velociyt of the object. (defaults to 0)
  • accy{Integer}: The starting y velocity of the object. (defaults to 0)
  • accz{Integer}: The starting z velocity of the object. (defaults to 0)
  • frames{Object}: This is stores the animation frames for the objects in a map style structure. An empty map means the default image will display with no animation frames. (defaults to an empty map)
  • shadow: (defaults to null)
  • //incomplete
  • maxacc{Integer}: (defaults to )4
  • controlmaxacc{Integer}: (defaults to 4)
  • responsive: (defaults to 0)
  • weapon: (defaults to 0)
  • camera{Boolean}: (defaults to true)
  • flipv{Boolean}: Notes if the object is flipped vertically(defaults to false)
  • fliph{Boolean}: Notes if the object is flipped horrizontally(defaults to false)
  • facing{Integer}: Stores the facing of the object. This is set with pre-defined Integer values from within Toys.(defaults to toys.FACE_DOWN)
    • FACE_UP:0,
    • FACE_RIGHT:1,
    • FACE_DOWN:2,
    • FACE_LEFT:3,
  • flipside{Boolean}: (defaults to true)
  • haspushing{Boolean}: (defaults to false)
  • frame: (default to 0)
  • colh{Integer}: (defaults to gbox.getTiles(th.tileset).tilehh)
  • colw{Integer}: (defaults to gbox.getTiles(th.tileset).tilew)
  • colx{Integer}: (defaults to 0)
  • staticspeed{Integer}: (defaults to 0)
  • nodiagonals{Boolean}: (defaults to false)
  • noreset: (defaults to false)
toys.topview.makedoor(gr, id, map, data)

										
									
Parameters:
gr
id
map
data
toys.topview.pixelcollides(fr, to, t)
Checks for pixel collisions with an offset to the X and Y of the colidable using colx and coly.

										
									
Parameters:
{Object} fr The object which collision is being tested for.
{Object} to The object (or point) which collision is being tested against.
{int} t The tollerance of the collision algorithm.
toys.topview.setFrame(th)
This sets which frame the object is going to display based on an agregate word that describes predefined states.

										
									
Parameters:
{Object} th The object whose frame is being set.
  • xpushing: a boolean that notes whether the object is pushing against something in the x direction.
  • ypushing: a boolean that notes whether the object is pushing against something in the y direction.
  • haspushing: a boolean that notes if the object changes when pushing against something.
  • toucheddown: a boolean that notes if the object is touching something below it on the screen.
  • touchedup: a boolean that notes if the object is touching something above it on the screen.<
  • touchedright: a boolean that notes if the object is touching something right of it on the screen.<
  • touchedleft: a boolean that notes if the object is touching something left of it on the screen.<
  • flipside:
  • fliph:
  • facing:
  • frames:
  • frame:
  • counter:
// incomplete
toys.topview.setStaticSpeed(th, speed)

										
									
Parameters:
th
speed
toys.topview.spawn(th, data)
Spawns a new object in the topview namespace. This also merges parameters in data into paramaters in th using help.copyModel. This initializes some basic basic variables for the object and sets the Z index.

										
									
Parameters:
{Object} th References 'this' which is the object that called the method (generally).
  • y {Integer}: (required) The object's y position.
  • h {Integer}: (required) The object's height.
{Object} data This holds variables to be merged into th's stored info.
toys.topview.spritewallCollision(th, data)

										
									
Parameters:
{Object} th The object being checked for collisions.
{Object} data This is used to pass in other data and arguments.
  • group {String}: (required) This is the group of objects being checked against.
//incomplete
toys.topview.tileCollision(th, map, tilemap, defaulttile, data)
Checks if the specified object is colliding with tiles in the map in an area defined by the object's colw and colh variables as well as the tolerance and approximation variables that are passed in through data. Only tiles in the map marked as solid are checked against. The alogrithm checks the

										
									
Parameters:
{Object} th The object that is being checked against the tilemap.
{Object} map This is the asci map that the tile map is generated from.
{Object} tilemap This is the array of tile objects that it itterated over checking for collisions.
{Object} defaulttile The default tile to be returned if nothing can be found. Null can be used here.
{Object} data Passes is extra dat to the function. Can be set as null.
  • tolerance{Integer}: This is subtracted from the collision space to get the maximum collision area for the object. This defaults to 6.
  • approximation{Integer}: This is the amount that the checked values are incremented by until they reach the maximum value allowed. This defaults to 10.
toys.topview.wander(th, map, tilemap, defaulttile, data)

										
									
Parameters:
th
map
tilemap
defaulttile
data
Documentation generated by JsDoc Toolkit 2.3.2 on Wed Aug 18 2010 16:09:25 GMT-0400 (EDT)