The game object contains essential game related properties
Properties:
Name | Type | Default | Description |
---|---|---|---|
gravity |
MC.Point | The Global gravity acceleration vector to be applied to all Sprites which have their gravity property set to true
Set at initialisation to (0,0) |
|
deltaTime |
Number | The time in SECONDS since the last frame
Refreshed by calling the MC.game.update() method within any game loop requestAnimationFrame() calls So useful some developers use var DT = MC.game.deltaTime; as a shortcut |
|
oldTime |
Number | Time of the previous frame
WARNING: used internally by the MC engine. DO NOT MODIFY Initialised to Game Start time. |
|
bounds |
Object | Comprising top, bottom, left and right.
These are the ratio of the actual canvas to be to be considered the "game boundry" for the purposes of Sprite edge checks. Set to the whole canvas at initialisation. i.e. (top: 0, bottom: 1, left: 0, right: 1) e.g. a 800 x 600px canvas could have it's bounds set to (top: 0, bottom: 1, left: 0.25, right: 0.75) in which case the game boundries would be a 400px central column in the middle of the canvas. |
|
physicsUpdates |
Number | 1 | The number of physics updates to be applied each during the update cycle |
mouse |
MC.Point | The canvas coordinates of the user mouse pointer (and mirrors MC.mouse.pos)
This is usually considered important enough for Developers to move it into Global name space with var mouse = MC.game.mouse. Allowing simple mouse.x and mouse.y to be used |
|
paused |
Boolean | false | When true then MC.game.deltaTime will not update |
text |
MC.Typeface | Defining the default MC.Engine text font, size and color. Used by any text when nothing else is defined. Initialised by MC.init() | |
conBoxDefaults |
Object | Set during MC.init() This container object holds the default values for the MC.ConBox objects.
N.B. ConBox default font is the same as the above MC.game.text.font value. Edit these to save having to do it for every new box. Values colorBody (default = "Orange") colorBodyHover (default = "DarkGreen") colorEdge (default = "Black") colorEdgeHover (default = "White") edgeWidth (default = 5) |
Methods
(static) fpsLog()
Displays the game FPS (0 is paused) in the top left of the canvas
Drawn using the MC.game.text default Typeface
FPS is logged in 10fps increments (to render it legible)
(static) mouseLog()
Displays the mouse co-ordinates in the bottom left of the canvas
Drawn using the MC.game.text default Typeface
(static) resetBounds()
Resets the game boundaries to mirror the full canvas height/width i.e. the equivalent of calling setBounds(0,1,0,1);
(static) setBounds(top, bottom, left, right)
Sets the game boundaries on the canvas (as proportions of canvas height and width)
All parameters are clamped to 0-1
Parameters:
Name | Type | Description |
---|---|---|
top |
Number | Top boundary |
bottom |
Number | Bottom boundary |
left |
Number | Left boundary |
right |
Number | Right boundary |
(static) update()
Call this method in any requestAnimationFrame() to update MC.game.deltaTime
If paused (i.e. MC.game.paused == true) deltaTime is set to 0 (zero)