mort 8 лет назад
Родитель
Сommit
aa89dcd4cb
2 измененных файлов: 10 добавлений и 2 удалений
  1. 4
    1
      es/game.js
  2. 6
    1
      es/script.js

+ 4
- 1
es/game.js Просмотреть файл

@@ -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 Просмотреть файл

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

Загрузка…
Отмена
Сохранить