change dir stucture

This commit is contained in:
Zutatensuppe 2021-05-01 00:16:08 +02:00
parent e18b8d3b98
commit 62f8991e11
26 changed files with 8718 additions and 804 deletions

31
public/gameloop.js Normal file
View file

@ -0,0 +1,31 @@
export const run = options => {
const fps = options.fps || 60
const slow = options.slow || 1
const update = options.update
const render = options.render
const raf = window.requestAnimationFrame
const step = 1 / fps
const slowStep = slow * step
let now
let dt = 0
let last = window.performance.now()
const frame = () => {
now = window.performance.now()
dt = dt + Math.min(1, (now - last) / 1000) // duration capped at 1.0 seconds
while (dt > slowStep) {
dt = dt - slowStep
update(step)
}
render(dt / slow)
last = now
raf(frame)
}
raf(frame)
}
export default {
run
}