You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

script.js 459B

1234567891011121314151617181920
  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", startGame);