samples/space-tank/main.js
// Main function which is called from the html
Main function which is called from the html
Main function which is called from the html
function main()
{
  TANK.createEngine(['EnemySpawner', 'Input', 'CollisionManager', 'Renderer2D']);
  TANK.main.Renderer2D.context = document.querySelector('#canvas').getContext('2d');
  TANK.main.Renderer2D.camera.y = -200;
  TANK.start();
  var e = TANK.createEntity('Player');
  TANK.main.addChild(e);
  e = TANK.createEntity('Ground');
  TANK.main.addChild(e, 'Level');
}
function main ( ) { TANK . createEngine ( [ 'EnemySpawner' , 'Input' , 'CollisionManager' , 'Renderer2D' ] ) ; TANK . main . Renderer2D . context = document . querySelector ( '#canvas' ) . getContext ( '2d' ) ; TANK . main . Renderer2D . camera . y = - 200 ; TANK . start ( ) ; var e = TANK . createEntity ( 'Player' ) ; TANK . main . addChild ( e ) ; e = TANK . createEntity ( 'Ground' ) ; TANK . main . addChild ( e , 'Level' ) ; }
Main function which is called from the html
Main function which is called from the html
// Create the main engine entity and add some components to it // Components on the main entity are usually 'system' components // that work with collections of entities or do other non-individual // things // Set the context of the renderer component from our canvas // And also set an initial camera y // Start the main loop, which also initializes the TANK.main entity // Create the player entity using the Player component // Create the ground entity, and name it Level so we // can find it later