some fixes
This commit is contained in:
parent
f8b014507f
commit
656f06291c
3 changed files with 31 additions and 19 deletions
|
@ -11,13 +11,18 @@ class NPC {
|
|||
this.you = you || uuidv4();
|
||||
|
||||
this.type = 'NPC';
|
||||
|
||||
|
||||
this.immortal = true;
|
||||
}
|
||||
handleTick(game) {
|
||||
let { entities } = game;
|
||||
|
||||
let rEntity = entities[Math.floor(Math.random() * entities.length)];
|
||||
let rEntity, i = 0;
|
||||
|
||||
while ((!rEntity || rEntity.type != 'Player') && i < 100) {
|
||||
rEntity = entities[Math.floor(Math.random() * entities.length)];
|
||||
i++;
|
||||
}
|
||||
|
||||
this.vel.x += (rEntity.pos.x - this.pos.x) * 0.0001;
|
||||
this.vel.y += (rEntity.pos.y - this.pos.y) * 0.0001;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue