+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.
// Initialization functions
this._initializeCanvas();
+ this._initializePixi();
this._initializeSystems();
this._initializeEntities();
}
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.
_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
+ }
+ });
}
};