a munch adventure
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

80 lignes
1.6 KiB

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