Provides basic setup functionality

Package gma/manager



Holds the width of the canvas

Type Number
Default 800


Holds the height of the canvas

Type Number
Default 600


Id for the gamma div

Type String
Default “gamma”


The gamma div

Type Element
Default $(“#gamma”)


Holds the canvas

Type DOM Element


Helper object connecting manager to rendering library

Type gma.sceneHelper


List of resources to give the renderer

Type [String]


The manager’s levelParser object

Type gma.levelParser


Holds the level specs

Type List
Default []


Holds the level index. (a level must be loaded first for it to be accurate)

Type Number
Default 0


Holds the hud

Type gma.hud


Specifies whether it should display a loading message

Type Boolean
Default true


Holds a character object
This is optional
Type gma.character
Default undefined


Holds the last time scene was rendered

Type Number


Holds an accumulation of time to be used for fps calculation

Type Number
Default 0


Holds the frames per second

Type Number
Default 0


Number of times the scene has twitched since fps last calculated

Type Number
Default 0


getFPS ( ) -> Number
Get the current FPS
background ( ) -> Array
Returns a list of all background
entities ( ) -> Array
Returns a list of all entities in the current level
determineObject (type, opts) -> Gamma Object
Returns a gamma object given the type given
If type is a string, then we look on gma to see if it exists
Otherwise it is used as is
And any options supplied in the opts object is applied to this object
type Gamma Object or string Name of a gamma object or just a gamma object
opts Gamma Object or string Name of a gamma object or just a gamma object
prepareEntity (focus, template, opts) -> Gamma Object
Attaches renderHelper and renderTemplate to the gamma object given
Also applies any extra options to this Gamma object
focus Gamma Object Gamma object
template renderTemplate A renderTemplate object to be given to the gamma object
opts {} Options to be applied to the gamma object
addCustomDefinitions (opts)
Gives an object othe levelParser to process, without storing the result anywhere
Useful for giving the levelParser type and template specifications
Which end up stored on the levelParser
opts Object Options that are given to the levelParser
storeLevels (levels, replaceAll)

Stores level specifications on the manager

levels Array A list of level objets to store
replaceAll Boolean Flag specifying whether to replace all current levels
loadLevel (level, spawnId)
Will load the specified level into the manager
Or the first level in self.levels if no level is specified
Or complain if manager has no stored levels
It will also remove any current levels in the manager
And set the position of the character according to the spawn location specified
level Number The index of the level to load
spawnId String Id of the spawn location for character
clearLevel ( )
Clears the current level from the scenehelper
init (level, spawn)
Called when we want the game to start
It creates a Scene and then starts the twitch
It will also call loadLevel if no level is currently loaded
Or if a level has been specified
level Number The index of the level to load
spawn String Alternate spawn point to use
twitch (self)
The game loop function
Responsible for :
  • Calling animate
  • Calling render
  • Calculating fps
  • Removing entities that are dead
  • Calling itself again to continue the loop
self gma.manager
animate (tick)

Calls the animate function on objects inside the map

tick Integer Number representing the time since the last twitch
removeDead (entities, cemetry)

Removes any dead entities from the map

entities List List of entities to look through
cemetry List List to add dead entities to if they have the reincarnate tag
checkCharacter ( )
Determines if the character is dead and does something about it if it is
respawn (spawnId)

Puts character back to the beginning

spawnId String String specifying where to respawn the character. This defaults to “main”

Table Of Contents

Fork me on GitHub