add enemy
This commit is contained in:
parent
276e11fb49
commit
edd005cb4d
7 changed files with 137 additions and 10 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue