add enemy

This commit is contained in:
biglyderv 2024-11-25 14:14:21 -05:00
parent 276e11fb49
commit edd005cb4d
7 changed files with 137 additions and 10 deletions

View file

@ -10,13 +10,19 @@ class Entity {
let ent = this;
let { width, height } = game;
let bounced = false;
if (Math.abs(ent.pos.x) >= width / 2) {
ent.vel.x = (Math.abs(ent.vel.x) + 10) * -Math.sign(ent.pos.x);
bounced = true;
}
if (Math.abs(ent.pos.y) >= height / 2) {
ent.vel.y = (Math.abs(ent.vel.y) + 10) * -Math.sign(ent.pos.y);
bounced = true;
}
return bounced;
}
}