These 32 files and commands come from the same configuration used by the download.
Entry point: src/main.ts
import { createUI } from "./ui"
import { Application, Graphics } from "pixi.js"
import "./style.css"
import { advanceScore } from "./score"
import { createSimulation } from "./simulation"
import { createInput } from "./input"
const simulation = createSimulation({ x: 400, y: 280, speed: 250, minX: 14, maxX: 786, minY: 14, maxY: 546 })
const app = new Application()
await app.init({ width: 800, height: 560, background: "#101e29", preference: "webgl", antialias: true })
app.canvas.tabIndex = 0
app.canvas.setAttribute("aria-label", "Game. Use arrow keys to collect gold.")
document.querySelector("#game")?.append(app.canvas)
const controls = createInput(app.canvas)
const player = new Graphics().roundRect(-14, -14, 28, 28, 5).fill(0xb5f46a)
player.position.set(400, 280)
const collectible = new Graphics().circle(0, 0, 11).fill(0xffc77a)
collectible.position.set(580, 280)
app.stage.addChild(player, collectible)
const ui = createUI()
window.addEventListener("pagehide", () => ui.dispose(), { once: true })
let score = 0
app.ticker.add((ticker) => {
if (ui.isPaused()) return
const position = simulation.step(controls.read(), ticker.deltaMS / 1000)
player.position.set(position.x, position.y)
if (Math.hypot(player.x - collectible.x, player.y - collectible.y) < 28) {
score = advanceScore(score)
const label = document.querySelector("#score")
if (label) label.textContent = "Collected: " + score
collectible.position.set(35 + Math.random() * 730, 70 + Math.random() * 455)
}
})
window.addEventListener("pagehide", () => app.destroy(true, { children: true }), { once: true })