Class Punx.Grid
Represents the game engine. Houses the main loop and canvas DOM node reference.
Defined in: punx.dist.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Punx.Grid(args)
|
Field Attributes | Field Name and Description |
---|---|
<private> |
Viewport canvas DOM element.
|
<private> |
Imaginary canvas DOM element used as a frame-buffer for collision detection and other graphics analysis.
|
<private> |
The game loop, an interval that calls update() on the current screen, timed according to fps.
|
Viewport canvas context.
|
|
Integer frames-per-second.
|
|
Internal frame counter, increments once after every update cycle, wraps at fps.
|
|
Integer canvas height.
|
|
Imaginary canvas context.
|
|
For debugging, causes the main loop to idle when true.
|
|
Required: Key of the initial screen.
|
|
Required: Object holding all screens, keyed by name.
|
|
Integer canvas width.
|
Method Attributes | Method Name and Description |
---|---|
<private> |
_update()
The main loop calls this once every fps.
|
create(parentElement)
Creates the canvases and injects the main canvas into the viewport.
|
|
start()
Starts the main loop.
|
Field Detail
<private>
_canvas
Viewport canvas DOM element. This is displayed.
<private>
_icanvas
Imaginary canvas DOM element used as a frame-buffer for collision detection and other graphics analysis. Scratch-space. Never shown.
<private>
_loop
The game loop, an interval that calls update() on the current screen, timed according to fps.
ctx
Viewport canvas context.
{number}
fps
Integer frames-per-second.
- Default Value:
- 60
{number}
frame
Internal frame counter, increments once after every update cycle, wraps at fps. This should be treated as read-only.
- Default Value:
- 0
{number}
h
Integer canvas height.
- Default Value:
- 540
ictx
Imaginary canvas context.
{boolean}
idle
For debugging, causes the main loop to idle when true.
- Default Value:
- false
{string}
screen
Required: Key of the initial screen.
{object}
screens
Required: Object holding all screens, keyed by name.
{number}
w
Integer canvas width.
- Default Value:
- 960
Method Detail
<private>
_update()
The main loop calls this once every fps. The loop is killed if any errors occur. Does nothing if idle is true.
create(parentElement)
Creates the canvases and injects the main canvas into the viewport.
- Parameters:
- parentElement Optional, Default: document.body
- DOM element to make the canvas a child of.
start()
Starts the main loop.