summaryrefslogtreecommitdiffstats
path: root/js-platformer/src/engine.js
diff options
context:
space:
mode:
Diffstat (limited to 'js-platformer/src/engine.js')
-rw-r--r--js-platformer/src/engine.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/js-platformer/src/engine.js b/js-platformer/src/engine.js
new file mode 100644
index 0000000..7dc9ddc
--- /dev/null
+++ b/js-platformer/src/engine.js
@@ -0,0 +1,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; \ No newline at end of file