a munch adventure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

27 line
657 B

  1. function initGame(game, state) {
  2. state.info = {};
  3. state.info.time = 60 * 60 * 9;
  4. }
  5. // TODO: format string this lol
  6. function renderTime(time) {
  7. let hours = Math.floor(time / 3600) % 12;
  8. const ampm = Math.floor(time / 3600) % 24 < 12 ? "AM" : "PM";
  9. let minutes = Math.floor(time / 60) % 60;
  10. let seconds = time % 60;
  11. if (minutes <= 9)
  12. minutes = "0" + minutes;
  13. if (seconds <= 9)
  14. seconds = "0" + seconds;
  15. return hours + ":" + minutes + ":" + seconds + " " + ampm;
  16. }
  17. function updateWorldInfo(state) {
  18. const timeInfo = document.querySelector("#world-info-time");
  19. timeInfo.textContent = "Time: " + renderTime(state.info.time);
  20. }