Browse Source

done things

master
mort 8 years ago
parent
commit
aa89dcd4cb
2 changed files with 10 additions and 2 deletions
  1. 4
    1
      es/game.js
  2. 6
    1
      es/script.js

+ 4
- 1
es/game.js View File

@@ -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);
}
}

+ 6
- 1
es/script.js View File

@@ -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();
});
});

Loading…
Cancel
Save