a munch adventure
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 

73 wiersze
1.4 KiB

  1. "use strict"
  2. let audioContext;
  3. let state = {
  4. player: {
  5. items: {
  6. keys: [
  7. ]
  8. },
  9. rooms: {
  10. }
  11. }
  12. }
  13. function print(lines) {
  14. (lines.concat([String.fromCharCode(160)])).forEach(line => {
  15. const log = document.querySelector("#log");
  16. const div = document.createElement("div");
  17. div.textContent = line;
  18. log.appendChild(div);
  19. });
  20. log.scrollTop = log.scrollHeight;
  21. }
  22. function refresh() {
  23. updateRoom(state);
  24. updateWorldInfo(state);
  25. updatePlayerInfo(state);
  26. }
  27. // set up the game
  28. function init(story) {
  29. initWorld(story, state);
  30. initAudio(story, state);
  31. initGame(story, state);
  32. goToRoom("Home", state);
  33. }
  34. // set up the load screen
  35. function initStart() {
  36. const select = document.querySelector("#game-select");
  37. const options = {};
  38. stories.forEach(story => {
  39. const option = document.createElement("option");
  40. option.value = story.id;
  41. option.textContent = story.name;
  42. select.appendChild(option);
  43. options[story.id] = story;
  44. })
  45. const start = document.querySelector("#start-button");
  46. start.addEventListener("click", (event) => {
  47. init(options[select.value]);
  48. document.querySelector("#pick").classList.remove("scene");
  49. document.querySelector("#pick").classList.add("hidden-scene");
  50. document.querySelector("#game").classList.remove("hidden-scene");
  51. document.querySelector("#game").classList.add("scene");
  52. });
  53. }
  54. window.addEventListener("load", initStart);