function initGame(game, state) { state.info = {}; state.info.time = 60 * 60 * 9; state.player.stats = {}; state.player.stats.health = 100; } // TODO: format string this lol function renderTime(time) { let hours = Math.floor(time / 3600) % 12; const ampm = Math.floor(time / 3600) % 24 < 12 ? "AM" : "PM"; let minutes = Math.floor(time / 60) % 60; let seconds = time % 60; if (minutes <= 9) minutes = "0" + minutes; if (seconds <= 9) seconds = "0" + seconds; return hours + ":" + minutes + ":" + seconds + " " + ampm; } function updateWorldInfo(state) { const timeInfo = document.querySelector("#world-info-time"); timeInfo.textContent = "Time: " + renderTime(state.info.time); } function updatePlayerInfo(state) { const health = document.querySelector("#player-info-health"); health.textContent = "Health: " + state.player.stats.health; }