CabinGame/Program/src/index.ts
Ronja b83024ded6 different UI for player inspection and adventure planning
also tons of tiny linter changes I guess
2020-04-24 15:01:39 +02:00

44 lines
1.1 KiB
TypeScript

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"
// 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)
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() {
setup()
// Run!
Ticker.shared.add((delta: number) => {
let time = performance.now()
// Run all the systems
globals.world.execute(delta / 100, time)
})
}