display run duration

This commit is contained in:
2026-02-20 08:52:31 -08:00
parent a238793cdc
commit 3dea810a50
4 changed files with 51 additions and 21 deletions

View File

@@ -23,26 +23,32 @@
width: 100%;
height: 100%;
}
.hud {
position: fixed;
bottom: 10px;
left: 10px;
display: flex;
flex-direction: column; /* stack vertically */
gap: 4px; /* space between timers */
}
.timer {
background: #000;
color: #fff;
padding: 4px 8px;
font-family: sans-serif;
font-size: 14px;
border-radius: 3px;
}
</style>
<script defer src="player.js" type="module"></script>
<script defer type="module" src="iframe-helper.js"></script>
</head>
<body>
<canvas id="viewport"> </canvas>
<div
id="timer"
style="
position: fixed;
bottom: 10px;
left: 10px;
background: #000;
color: #fff;
padding: 4px 8px;
font-family: sans-serif;
font-size: 14px;
"
>
00:00:00
<div class="hud">
<div id="duration" class="timer">00:00:00</div>
<div id="timer" class="timer">00:00:00</div>
</div>
</body>
</html>

View File

@@ -21,6 +21,7 @@ graphics.change_map(map);
const startTime = performance.now();
const timer = document.getElementById("timer");
const duration = document.getElementById("duration");
const MODE_MAIN = 0;
function timer_text(t) {
@@ -31,6 +32,8 @@ function timer_text(t) {
return `${String(h).padStart(2, "0")}:${String(m).padStart(2, "0")}:${String(s).padStart(2, "0")}.${String(ms).padStart(3, "0")}`;
}
duration.textContent = timer_text(bot.run_duration(MODE_MAIN));
function animate(now) {
const elapsedMs = now - startTime;
const elapsedSec = elapsedMs / 1000; // wasm expects seconds