feat: fancy clouds, fps meter

This commit is contained in:
Dan Finch 2026-08-04 03:00:58 +02:00
parent b0878ad5e1
commit 2c31bd82bf
5 changed files with 120 additions and 26 deletions

View file

@ -14,6 +14,7 @@ const screen = document.querySelector<HTMLCanvasElement>("#screen")!
const ctx = screen.getContext("2d")!
const back = document.createElement("canvas")
const backCtx = back.getContext("2d")!
const fpsEl = document.querySelector<HTMLDivElement>("#fps")!
let config: RenderConfig = RenderConfig.standard
let fb = Framebuffer.create(1, 1)
@ -82,9 +83,17 @@ async function main(): Promise<void> {
resize()
let last = performance.now()
let fpsLast = last
let fpsFrames = 0
function frame(now: number): void {
const dt = Math.min(0.05, (now - last) / 1000)
last = now
fpsFrames++
if (now - fpsLast >= 250) {
fpsEl.textContent = `${Math.round((fpsFrames * 1000) / (now - fpsLast))} fps`
fpsLast = now
fpsFrames = 0
}
Player.update(player, keys, dt, level)
const camera: Camera = {