CabinGame/Program/src/index.ts

44 lines
1.1 KiB
TypeScript
Raw Normal View History

import { Application, settings, SCALE_MODES, Ticker } from "pixi.js";
import globals from "./globals";
import { canvasWidth, canvasHeight } from "./constants";
import { loadResources } from "./resources";
import { setup } from "./setup";
2020-02-17 11:56:41 +00:00
// Initialize pixi
globals.app = new Application({
width: canvasWidth,
height: canvasHeight,
backgroundColor: 0x10101010,
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"
}
loadResources(init)
function init(){
2020-02-17 11:56:41 +00:00
setup()
// Run!
Ticker.shared.add((delta : number) => {
let time = performance.now()
// Run all the systems
globals.world.execute(delta/100, time)
});
}