title
Index Features Getting Started Sample Games JSDoc Creators Github

Click here to download templates to create a game

Javascript Template
Website Template

To download the game engine and see code for sample games go to: our github page

Please see our JSDoc for an API reference for each class, and see our github to download the engine. The engine is entirely contained within the "engine" folder, though you only need to include engine.js, and the "Examples" folder contains the code for the example games that are on this site.

The Game

The very basic line you need to start a game is:
var game = new Game(document.getElementById("canvas"), "gamename");

This gives you access to the game object which is how you will control everything in your game. In the game object you have access to a scene graph for the sprites, objects, score, and the game manager.

Everytime you want to add an object, sprite, or score to the game, you must add it to the Scenegraph that is relates to or else it won't show up on the canvas. To help organize your objects, feel free to create more scenegraphs and add them to the existing scene graphs.

For example, if you want to add a scene graph for a particle object you must push the scene graph to the object scene graph to have it show up on the canvas.

game.objects.push(new SceneGraph("example", true, true, false));

The Game Manager

The game manager will help you create events to happen in the game based on certain condition, time, etc. There is one game manager per game and it is created when the game is made so there is no need to define your own.

Starting a game

By editing the function, game.setup = function(){}, anything inside of that function will be the first code that the game will read before starting a new game. This function must be called at the end of the file so the game will setup before officially starting. This is where you will initlize any objects needed for the game. Use this function everytime you want to start a new game. You can then start the game using game.start(10); to start the game updating. The number in the parameter is how many milliseconds between each update. So if you want there to be one second between updates the number you would need is 1000.

Creating GameObjects

With the nature of javascript, this is a generic setup for each GameObject.

function ObjectName(){
  var self = this;

  self.constructor = function(){
    GameObject.call(self,"objectName",sprite,x,y);
  }
  self.constructor();

  self.customUpdate = function(game){

  }
}
Use the name self to refer to the object throughout the function. When creating a game object use the customUpdate to create specific updates for your object!
Remember to add your objects to a SceneGraph!