summaryrefslogtreecommitdiffstats
path: root/js-platformer/src/engine.js
blob: 7dc9ddc3abf46e8bde932e36877efd308f4c0d24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
var Engine = function() {

	this.stage = new PIXI.Stage(settings.STAGE_BGCOLOR);
	this.renderer = PIXI.autoDetectRenderer(settings.STAGE_WIDTH, settings.STAGE_HEIGHT);

	this.gameObjectList = [];

	this.update = function() {
		for (var i = 0; i < this.gameObjectList.length; i++) {
			this.gameObjectList[i].update();
		}


		this.renderer.render(this.stage);
	}

	this.addGameObject = function(gameObject) {
		this.gameObjectList.push(gameObject);
		this.stage.addChild(gameObject.sprite);
	}

	return this;
}

var engine = new Engine();
Engine.instance = engine;