a munch adventure
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 

27 Zeilen
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. }