diff options
Diffstat (limited to 'src/index.html.in')
-rw-r--r-- | src/index.html.in | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/index.html.in b/src/index.html.in index 6147475..14731f6 100644 --- a/src/index.html.in +++ b/src/index.html.in @@ -33,6 +33,7 @@ const INPUT_CLICK = 1; const INPUT_RCLICK = 2; const INPUT_PAUSE_PLAY = 3; const INPUT_MOVE = 4; +const INPUT_RESTART = 5; const WASM = #include "../build/main.wasm.b64" @@ -43,6 +44,14 @@ const MUSIC = const IMAGES = [ #include "../build/continue.png.b64" , +#include "../build/exit.png.b64" +, +#include "../build/pause.png.b64" +, +#include "../build/play.png.b64" +, +#include "../build/restart.png.b64" +, ]; async function main() { @@ -94,6 +103,9 @@ async function main() { let len = dl[0]; let ops = dl.subarray(1); + ctx.fillStyle = "#000000"; + ctx.fillRect(0, 0, width, height); + console.log("frame"); for (let i = 0; i < len; i++) { let op = ops.subarray(7*i, 7*i+7); const color = new Uint8Array(new Uint32Array(op.subarray(4, 6)).buffer); @@ -104,6 +116,7 @@ async function main() { ctx.globalAlpha = color[7] / 255; ctx.strokeRect(op[0], op[1], op[2], op[3]); if (op[6] !== 0) { + ctx.globalAlpha = 1; ctx.drawImage(images[op[6]], op[0], op[1], op[2], op[3]); } } @@ -140,14 +153,16 @@ async function main() { document.addEventListener("keydown", function (e) { if (e.key === " ") { - exports.game_update(INPUT_PAUSE_PLAY, 0, 0, now()); + exports.game_update(INPUT_PAUSE_PLAY, mousex, mousey, now()); + } else if (e.key == "r") { + exports.game_update(INPUT_RESTART, mousex, mousey, now()); } }); function animate() { // TODO: stop requesting frames when state is static requestAnimationFrame(animate); - exports.game_update(INPUT_NONE, 0, 0, now()); + exports.game_update(INPUT_NONE, mousex, mousey, now()); render(); } requestAnimationFrame(animate); |