]> git.r.bdr.sh - rbdr/sumo/blobdiff - lib/sumo.js
Render Sumo (#3)
[rbdr/sumo] / lib / sumo.js
index da72991982c6ea6831699ac23d3eb005c686d8f4..81f948f74848695144ca298d546e6a6b66714fa5 100644 (file)
@@ -1,8 +1,12 @@
+import RenderSystem from './systems/render';
+import SumoFactory from './factories/sumo';
 import Serpentity from '@serpentity/serpentity';
+import { Application } from 'pixi.js';
 
 /* global window document */
 
 const internals = {
+  kBackgroundColor: 0xd8c590,
   kNoElementError: 'No element found. Cannot render.',
 
   // Handler for the window load event. Initializes and runs the app.
@@ -56,6 +60,7 @@ internals.Sumo = class Sumo {
 
     // Initialization functions
     this._initializeCanvas();
+    this._initializePixi();
     this._initializeSystems();
     this._initializeEntities();
   }
@@ -119,6 +124,18 @@ internals.Sumo = class Sumo {
     window.addEventListener('resize', this._resizeCanvas.bind(this));
   }
 
+  // Initialize Pixi
+
+  _initializePixi() {
+
+    this._pixi = new Application({
+      backgroundColor: internals.kBackgroundColor,
+      view: this._canvas,
+      width: this._canvas.width,
+      height: this._canvas.height
+    });
+  }
+
   // Resizes the canvas to a square the size of the smallest magnitude
   // of the window.
 
@@ -143,12 +160,28 @@ internals.Sumo = class Sumo {
 
   _initializeSystems() {
 
+    this._engine.addSystem(new RenderSystem({
+      application: this._pixi
+    }));
   }
 
   // Initializes the serpentity entities
 
   _initializeEntities() {
 
+    SumoFactory.createSumo(this._engine, {
+      position: {
+        x: 50,
+        y: 50
+      }
+    });
+
+    SumoFactory.createSumo(this._engine, {
+      position: {
+        x: 309,
+        y: 112
+      }
+    });
   }
 };