add map
This commit is contained in:
parent
7fbe113061
commit
8278445e88
4 changed files with 140 additions and 2 deletions
|
@ -50,7 +50,7 @@ Player.prototype.bump = function () {
|
|||
}
|
||||
|
||||
Player.prototype.handleTick = function (game) {
|
||||
let { entities } = game;
|
||||
let { entities, width, height } = game;
|
||||
|
||||
let ent = this;
|
||||
|
||||
|
@ -59,6 +59,9 @@ Player.prototype.handleTick = function (game) {
|
|||
ent.pos.x += ent.vel.x;
|
||||
ent.pos.y += ent.vel.y;
|
||||
|
||||
ent.pos.x = Math.max(Math.min(ent.pos.x, width / 2), - width / 2);
|
||||
ent.pos.y = Math.max(Math.min(ent.pos.y, height / 2), - height / 2);
|
||||
|
||||
ent.vel.x *= 0.9;
|
||||
ent.vel.y *= 0.9;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue