Namespace toys.topview
Top-view RPG specific libraries.
Defined in: toys.js.
Method Summary
adjustZindex(th)
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.
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)
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.
spritewallCollision(th, data)
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.applyForces(th)
Sets the objects current location to its next location using the getNextX and getNextY methods.
Parameters:
{Object} | th |
The object being modified.
|
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.
|
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.
|
{Object} | to |
The object that collision is being checked against.
|
{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)
|
{Object} | keys | These are the control keys being passed in for left, right, up, and down. //incomplete |
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.
|
{Object} | data |
This is used to pass in extra parameters.
|
toys.topview.getNextX(th)
Gets the next X position the object is going to move to.
Parameters:
{Object} | th |
The object being checked.
|
toys.topview.getNextY(th)
Gets the next Y position the object is going to move to.
Parameters:
{Object} | th |
The object being checked.
|
toys.topview.getNextZ(th)
Gets the next Z position the object is going to move to.
Parameters:
{Object} | th |
The object being checked.
|
toys.topview.handleAccellerations(th)
Degrades all accelerations on an object by one toward zero.
Parameters:
{Object} | th |
The object being modified.
|
toys.topview.handleGravity(th)
Increases the Z acceleration on the object by one.
Parameters:
{Object} | th |
The object being modified.
|
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.
|
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.
|
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). |
{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.
|
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.
|