diff options
| author | Raymaekers Luca <luca@spacehb.net> | 2025-10-03 02:05:42 +0200 |
|---|---|---|
| committer | Raymaekers Luca <luca@spacehb.net> | 2025-10-03 02:05:42 +0200 |
| commit | 732e6a47ded496cd224e1cfadc2106b04dcf6859 (patch) | |
| tree | 3ff22b5a6808e0970f8b94b15d162df2054078d9 /code/platform.js | |
| parent | 449514853850adca190d7eba679f386c024aa929 (diff) | |
checkpoint
Diffstat (limited to 'code/platform.js')
| -rw-r--r-- | code/platform.js | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/code/platform.js b/code/platform.js index fda3a49..163b0ad 100644 --- a/code/platform.js +++ b/code/platform.js @@ -2,7 +2,6 @@ var HEAPU8; //- Helper functions - function ReadHeapString(ptr, length) { if (length === 0 || !ptr) return ''; @@ -101,24 +100,19 @@ async function main() }; //- Game loop - var prev = null; - function frame(timestamp) + let prev = 0; + let timestamp = 0; + let update_hz = 30; + while(true) { - var dt = (timestamp - prev)*0.001; + let dt = (timestamp - prev)*0.001; prev = timestamp; - // TODO(luca): How to get this??? - var update_hz = 30; - instance.exports.RenderGradient(width, height, bytes_per_pixel, 1/update_hz, mouse_down, mouse_x, mouse_y); + instance.exports.UpdateAndRender(width, height, bytes_per_pixel, 1/update_hz, mouse_down, mouse_x, mouse_y); ctx.putImageData(image, 0, 0); - window.requestAnimationFrame(frame); - } - window.requestAnimationFrame((timestamp) => { - prev = timestamp; - window.requestAnimationFrame(frame); - }); + await new Promise(requestAnimationFrame); + } } - window.onload = main; |
