a munch adventure
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

27 строки
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. }