diff options
| author | Brian Cully <bjc@spork.org> | 2025-12-22 14:37:16 -0500 |
|---|---|---|
| committer | Brian Cully <bjc@spork.org> | 2025-12-22 14:37:16 -0500 |
| commit | e083a6720227e8cf2b03b94110607f9d5a50e1b6 (patch) | |
| tree | 1b4a989da1bed024d6bacaef67451ec380fce709 | |
| parent | 874834b026300fab646ccefdaceb33bc4ff499b7 (diff) | |
| download | automathon-e083a6720227e8cf2b03b94110607f9d5a50e1b6.tar.gz automathon-e083a6720227e8cf2b03b94110607f9d5a50e1b6.zip | |
html: add tick rate selector
| -rw-r--r-- | site/index.html | 9 | ||||
| -rw-r--r-- | site/main.mjs | 13 |
2 files changed, 19 insertions, 3 deletions
diff --git a/site/index.html b/site/index.html index dac9b4f..eeebbe9 100644 --- a/site/index.html +++ b/site/index.html @@ -19,6 +19,15 @@ <!-- <button id='bench'>bench</button> --> <button id='tick'>tick</button> <button id='blinken'>blinken</button> + <label for='tick-rate-select'>tps:</label> + <select id='tick-rate-select'> + <option>5</option> + <option>10</option> + <option selected>15</option> + <option>30</option> + <option>45</option> + <option>60</option> + </select> </div> <!-- controls --> </section> <!-- arena --> diff --git a/site/main.mjs b/site/main.mjs index 958e82d..859b8d0 100644 --- a/site/main.mjs +++ b/site/main.mjs @@ -1,10 +1,11 @@ // simulation speed -const TICKS_PER_SECOND = 12; -const MS_PER_TICK = 1_000 / TICKS_PER_SECOND; +let TICKS_PER_SECOND = 15; +let MS_PER_TICK = 1_000 / TICKS_PER_SECOND; // one per page const CANVAS_SELECTOR = '#arena canvas'; const TICK_BUTTON_SELECTOR = '#tick'; +const TICK_RATE_SELECTOR = '#tick-rate-select'; const BENCH_BUTTON_SELECTOR = '#bench'; const BLINKEN_BUTTON_SELECTOR = '#blinken'; @@ -187,7 +188,6 @@ async function loaded() { } break; case 'tick': - console.debug('bjc tick', robo.heading, trans.vars.heading); const { word, offset } = trans.ip; document.querySelectorAll(IP_SELECTOR).forEach(e => e.classList.remove('ip')); const sel = selectorForIP(word, offset); @@ -249,6 +249,13 @@ async function loaded() { roboWorker.postMessage({ kind: 'tick' }); }; + document.querySelector(TICK_RATE_SELECTOR).onchange = e => { + console.debug('tick rate changed', e, Number(e.target.value)); + TICKS_PER_SECOND = e.target.value; + MS_PER_TICK = 1_000 / TICKS_PER_SECOND; + } + document.querySelector(TICK_RATE_SELECTOR).onchange({target: { value: TICKS_PER_SECOND }}); + let blinkenRun = false; document.querySelector(BLINKEN_BUTTON_SELECTOR).onclick = e => { console.debug('blinken clicked', e); |
