Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

script.js 755B

12345678910111213141516171819202122232425262728293031323334
  1. let Game = require("./game");
  2. let game, sock;
  3. function startGame() {
  4. view("game");
  5. sock = new SockSugar(conf.address);
  6. game = new Game(sock, document.getElementById("canvas"));
  7. sock.on("close", () => {
  8. alert("Server closed.");
  9. game.stop();
  10. });
  11. game.onloss = () => view("game-over");
  12. }
  13. document.querySelector("#startGameBtn").addEventListener("click", startGame);
  14. document.querySelector("#restartGameBtn").addEventListener("click", () => {
  15. location.hash = "game";
  16. location.reload();
  17. });
  18. document.querySelector("#storyBtn").addEventListener("click", () => {
  19. location.hash = "";
  20. location.reload();
  21. });
  22. window.addEventListener("load", () => {
  23. if (location.hash.substring(1) === "game") {
  24. startGame();
  25. console.log("starting");
  26. }
  27. });