import GameBasic from "./common/game_basic.js"; class Game extends GameBasic { constructor() { super(); this.ws = []; } sync() { let { entities } = this; let entList = []; for (let entity of entities) { let { pos, vel, rot, dir, health, headCount, you, camera } = entity; entList.push({ pos, vel, rot, dir, health, headCount, you, camera }); } if (entList.length == 0) return; for (let client of this.ws) { if (!client.active) continue; client.send(JSON.stringify(entList)); } } init() { super.init(); let that = this; that.entities = []; setInterval(function () { that.sync() }, 1000 / 20); } } export default Game;