53 lines
1.2 KiB
TypeScript
53 lines
1.2 KiB
TypeScript
import {
|
|
getContext,
|
|
setContextItem,
|
|
setDefaultContext,
|
|
} from "./lib/context.ts";
|
|
import { InputManager } from "./lib/input.ts";
|
|
|
|
import { Doodler, Vector, ZoomableDoodler } from "@bearmetal/doodler";
|
|
import { ResourceManager } from "./lib/resources.ts";
|
|
import { addButton } from "./ui/button.ts";
|
|
import { TrackSystem } from "./track/system.ts";
|
|
import { StraightTrack } from "./track/shapes.ts";
|
|
import { StateMachine } from "./state/machine.ts";
|
|
import { bootstrapGameStateMachine } from "./state/states/index.ts";
|
|
|
|
const inputManager = new InputManager();
|
|
const resources = new ResourceManager();
|
|
const doodler = new ZoomableDoodler({
|
|
fillScreen: true,
|
|
bg: "#302040",
|
|
});
|
|
|
|
setDefaultContext({
|
|
inputManager,
|
|
doodler,
|
|
resources,
|
|
debug: true,
|
|
showEnds: true,
|
|
});
|
|
|
|
const state = bootstrapGameStateMachine();
|
|
setContextItem("state", state);
|
|
|
|
doodler.init();
|
|
addButton({
|
|
text: "Hello World!",
|
|
onClick: () => {
|
|
console.log("Hello World!");
|
|
},
|
|
at: [
|
|
new Vector(10, doodler.height - 50),
|
|
new Vector(110, doodler.height - 10),
|
|
],
|
|
style: {
|
|
fillColor: "blue",
|
|
color: "white",
|
|
},
|
|
});
|
|
|
|
doodler.createLayer((_, __, dTime) => {
|
|
state.update(dTime);
|
|
});
|