This is an automatically generated documentation page. For specific examples, check here!
Function: GameAudio.init(collection, containingFolder)
Starts the audio system, using an array of audio names 'collection' and a path 'containingFolder' in which the sounds can be found. Do not include file extentions in sound names!
plays a sound with the name 'name'.
Function: Engine.loadScripts(scripts, callback)
Include an array 'scripts' from an external source. When finished, start the function 'callback'.
array containing all existing objects.
Total amount of update steps since the start of the game.
Function: Game.initialize(windowX, windowY, windowWidth, windowHeight, fps, loadedCallback)
Starts the game, and creates a window at ('windowX', 'windowY'), using 'windowWidth' and 'windowHeight' as sizes for the game window in pixels. 'fps' controls the game's frames-per-second'. As soon as the game is loaded up, it'll call the function 'loadedCallback', so you can properly start the game.
Assigns a function 'callback(deltaTime)' to be called every frame of the game. You can use this to run global code for your game.
destroys every object in the scene.
Function: Constructor: new image(urlToImage, subImages = 1, subImagesPerRow = 1)
Function: image.draw(sourceX, sourceY, sourceWidth, destX, destY, destWidth, destHeight, rotation, alpha)
Draw the image on screen.
Image. Create using: new image(urlToImage)
Returns true if the key with given code 'keyCode' was pressed this frame. Only returns true the frame the key is pressed once until the key is released and pressed again.
returns true if the key with given code 'keyCode' is currently pressed.
Function: GameObject.create(template, x, y)
Creates a new Game Object using the object template 'template' at the position ('x', 'y')
Object is visible and executes it's code when this parameter is true. Set to false to hide and disable the object temporarily.
The name of the current object. Defaults to "Object".
An image object.
Ignores this object when checking for collisions. Useful for background objects.
Used for methods and variables related to drawing the object on the screen.
The image to draw.
The current subimage to draw using the default draw method
Image transparency (0-1) default: 1
Value indicating if the object should be drawn (true/false)
Function: image.draw(x, y, w, h, rotation, alpha = 1)
Draw an image at (x,y), size (w,h), at an angle in degrees.
A vector() containing the object's position. (measured from object center)
A vector() containing the object's speed. (measured from object center)
the object's rotation in degrees. Default is zero.
the width of the object, defaults to 32.
the height of the object, defaults to 32.
Adjust object.transform.rotation to point at vector2() 'point'.
A single pixel left of the object, accounting for rotation.
A single pixel right of the object, accounting for rotation.
A single pixel forwards of the object, accounting for rotation.
A single pixel backwards of the object, accounting for rotation.
Called on object's creation. Override this on your own object templates!
Called on each draw step. If not overridden, default draw is used!
Called on each frame start! (Before collision checks of this frame) Override this on your own object templates!
Called on object collision. Parameter 'other' is a reference to the object you're colliding with! Override this on your own object templates!
Destroys the current object at the end of the current update step.
Called on object's destruction. Override this on your own object templates!
the X axis of the vector.
the Y axis of the vector.
returns the length of the vector.
Get the angle towards the vector's direction in degrees.
returns a normalized copy of the vector. Original vector is not modified.
Function: vector.lerpTo(otherVector, t)
Returns a new vector between this vector and 'otherVector' at point 't'. 0t = original vector, 1t = 'otherVector', 0.5t is halfway in between.
returns the distance to another vector.
adds the two vectors together, and returns as a copy. Original vector is not modified.
subtracts the second vector from this vector, and returns as a copy. Original vector is not modified.
multiplies the first vector X by the second vector's X, and the first's Y by the second's Y, and returns as a copy. Original vector is not modified.
divides the first vector by the second, and returns as a copy. Original vector is not modified.
Multiplies the vector by the given numeric value, and returns as a copy. Original vector is not modified.
returns a copy of this vector.
The game window's width. Cannot be changed.
The game window's height. Cannot be changed.
Background color. Contains an r, g and b component (0-255).
The game's canvas element
The game's canvasContext. Use this for drawing.