-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
61 lines (50 loc) · 1.79 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import domready = require("domready");
import {LabelOptions} from "@dcgw/excalibur-extended-label";
import {BaseAlign, Color, DisplayMode, Engine, Loader, TextAlign} from "excalibur";
import Game from "./game/game";
import {version} from "./package.json";
import resources from "./resources";
import Title from "./title/title";
export const defaultLabelOptions: LabelOptions = {
fontFamily: "Knewave",
fontSize: 18,
textAlign: TextAlign.Center,
baseAlign: BaseAlign.Top,
color: Color.White,
outlineColor: new Color(0, 0, 0, 0.5),
outlineWidth: 1,
shadowColor: Color.Black,
shadowBlurRadius: 2
};
console.log(`Bunny Patrol v${version}`);
const width = 320;
const height = 240;
domready(() => {
const engine = new Engine({
viewport: {width, height},
resolution: {width, height},
displayMode: DisplayMode.Fixed,
antialiasing: false,
suppressHiDPIScaling: true
});
// Work around Firefox not supporting image-rendering: pixelated
// See https://github.com/excaliburjs/Excalibur/issues/1676
if (engine.canvas.style.imageRendering === "") {
engine.canvas.style.imageRendering = "crisp-edges";
}
const scale = (): void => {
const scaleFactor = Math.floor(
Math.min(window.innerWidth / width, window.innerHeight / height)
);
engine.screen.viewport = {width: width * scaleFactor, height: height * scaleFactor};
engine.screen.applyResolutionAndViewport();
};
scale();
const loader = new Loader(Object.values(resources));
void engine.start(loader).then(() => {
engine.addScene("title", new Title(engine));
engine.addScene("game", new Game(engine));
engine.goToScene("title");
});
window.addEventListener("resize", scale);
});