import { Application, Ticker, settings, SCALE_MODES } from "pixi.js" import { setup } from "./setup" import { loadResources } from "./Resources" import { DoorSystem } from "./Systems/DoorSystem" import { SpriteSystem } from "./Systems/rendering/SpriteSystem" import { RenderSystem } from "./Systems/rendering/RenderSystem" import { TestSystem } from "./Systems/TestSystem" import { AdventureReturnSystem } from "./Systems/AdventureReturnSystem" import { VisibleHumanSystem } from "./Systems/VisibleHumanSystem" import { DebugRenderSystem } from "./Systems/rendering/DebugRenderSystem" import { PixiCleanupSystem } from "./Systems/rendering/PixiCleanupSystem" import { ZOrderSystem } from "./Systems/rendering/ZOrderSystem" import { PathWalkerSystem } from "./Systems/PathWalkerSystem" import { RandomWalkSystem } from "./Systems/RandomWalkSystem" import { World } from "ecsy" import globals from "./globals" import { canvasWidth, canvasHeight } from "./constants" import { ClickableSystem } from "./Systems/ClickableSystem" // Initialize pixi globals.app = new Application({ width: canvasWidth, height: canvasHeight, backgroundColor: 0x000000, resolution: 1, antialias: false, }) document.body.appendChild(globals.app.view) settings.SCALE_MODE = SCALE_MODES.NEAREST settings.ROUND_PIXELS = true recalculateSize() window.addEventListener( 'resize', recalculateSize, false ) function recalculateSize(){ let multiplier = Math.min((window.innerWidth/canvasWidth)|0, (window.innerHeight/canvasHeight)|0) globals.app.view.style.width = canvasWidth * multiplier + "px" globals.app.view.style.height = canvasHeight * multiplier + "px" } // Create world and register the systems on it //we could also register components here but they should get automatically registered once used for the first time globals.world = new World() globals.world .registerSystem(TestSystem) //prio -100 .registerSystem(AdventureReturnSystem) //prio -100 .registerSystem(DoorSystem) //prio 0 .registerSystem(RandomWalkSystem) //prio 0 .registerSystem(PathWalkerSystem) //prio 50 .registerSystem(VisibleHumanSystem) //prio 50 .registerSystem(SpriteSystem) //prio 70 .registerSystem(ClickableSystem) //prio 80 .registerSystem(DebugRenderSystem) //prio 90 .registerSystem(ZOrderSystem) //prio 98 .registerSystem(PixiCleanupSystem) //prio 99 .registerSystem(RenderSystem) //prio 100 loadResources(init) function init(){ setup() // Run! Ticker.shared.add((delta : number) => { let time = performance.now() // Run all the systems globals.world.execute(delta/100, time) }); }