feat: fancy clouds, fps meter
This commit is contained in:
parent
b0878ad5e1
commit
2c31bd82bf
5 changed files with 120 additions and 26 deletions
|
|
@ -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 = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue