add emotes and npcs. this really needs a cleanup

This commit is contained in:
biglyderv 2024-11-25 14:14:20 -05:00
parent da4b0f5df8
commit f8b014507f
11 changed files with 267 additions and 85 deletions

13
game.js
View file

@ -1,4 +1,5 @@
import GameBasic from "./common/game_basic.js";
import NPC from "./common/npc.js";
class Game extends GameBasic {
constructor() {
@ -9,8 +10,8 @@ class Game extends GameBasic {
let { entities } = this;
let entList = [];
for (let entity of entities) {
let { pos, vel, rot, dir, health, headCount, you, camera, ticks } = entity;
entList.push({ pos, vel, rot, dir, health, headCount, you, camera, ticks });
let { pos, vel, rot, dir, health, headCount, you, camera, ticks, type, isMenu, r, playing } = entity;
entList.push({ pos, vel, rot, dir, health, headCount, you, camera, ticks, type, isMenu, r, playing });
}
if (entList.length == 0) return;
@ -19,6 +20,10 @@ class Game extends GameBasic {
if (!client.active) continue;
client.send(JSON.stringify(entList));
}
for (let entity of entities) {
entity.r = 1;
}
}
init() {
super.init();
@ -26,6 +31,10 @@ class Game extends GameBasic {
let that = this;
that.entities = [];
for (let i = 0; i < 10; i++) {
that.entities.push(new NPC())
}
setInterval(function () { that.sync() }, 1000 / 5);
}
}