| update() {} | update() {} | ||||
| send() {} | |||||
| send(first) {} | |||||
| despawn() { | despawn() { | ||||
| this.game.players.forEach((p) => p.sock.send("despawn", { | this.game.players.forEach((p) => p.sock.send("despawn", { | ||||
| req.reply({ | req.reply({ | ||||
| id: this.id | id: this.id | ||||
| }); | }); | ||||
| game.entities.forEach((e) => e.send(true)); | |||||
| } else if (req.url == "keydown") { | } else if (req.url == "keydown") { | ||||
| this.keys[req.data.key] = true; | this.keys[req.data.key] = true; | ||||
| } else if (req.url == "keyup") { | } else if (req.url == "keyup") { | ||||
| delete this.keys[req.data.key]; | delete this.keys[req.data.key]; | ||||
| } | } | ||||
| game.entities.forEach((e) => e.send(true)); | |||||
| }); | }); | ||||
| sock.on("close", () => this.despawn()); | sock.on("close", () => this.despawn()); | ||||
| this.health -= 10; | this.health -= 10; | ||||
| e.despawn(); | e.despawn(); | ||||
| if (this.health <= 0) | if (this.health <= 0) | ||||
| this.despawn(); | |||||
| this.despawn(); | |||||
| } | } | ||||
| } | } | ||||
| }); | }); |