X-Git-Url: https://git.r.bdr.sh/rbdr/sumo/blobdiff_plain/11be5ebabcdab8272d938f7b90ef0ea9be29a421..0616b3f00653c66b5e34814653e33413b9ec034e:/lib/sumo.js?ds=sidebyside diff --git a/lib/sumo.js b/lib/sumo.js index da72991..81f948f 100644 --- a/lib/sumo.js +++ b/lib/sumo.js @@ -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 + } + }); } };