| @@ -152,7 +152,6 @@ export default class Game { | |||
| }); | |||
| sock.on("set", (msg) => { | |||
| console.log(msg); | |||
| if (!this.entities[msg.id]) | |||
| this.entities[msg.id] = createEntity(msg); | |||
| else | |||
| @@ -213,4 +212,8 @@ export default class Game { | |||
| this.raf = window.requestAnimationFrame(this.update.bind(this)); | |||
| } | |||
| stop() { | |||
| window.cancelAnimationFrame(this.raf); | |||
| } | |||
| } | |||
| @@ -2,6 +2,11 @@ let Game = require("./game.js"); | |||
| document.querySelector("#startGameBtn").addEventListener("click", () => { | |||
| view("game"); | |||
| let sock = new SockSugar("ws://localhost:8081"); | |||
| let sock = new SockSugar("ws://serve.mort.coffee:89"); | |||
| let game = new Game(sock, document.getElementById("canvas")); | |||
| sock.on("close", () => { | |||
| alert("Server closed."); | |||
| game.stop(); | |||
| }); | |||
| }); | |||