summaryrefslogtreecommitdiff
path: root/src/systems/physics.js
diff options
context:
space:
mode:
authorLogan Hunt <loganhunt@simponic.xyz>2022-04-02 23:27:07 -0600
committerLogan Hunt <loganhunt@simponic.xyz>2022-04-02 23:27:07 -0600
commitbb75e40de92fb7e0589410b67e21087f27f34f45 (patch)
tree9c884185bd5feb9d505c4c0ca9a35b31ffb90696 /src/systems/physics.js
parentcf4dbf91ddb980c051ee2905367143d433c376a5 (diff)
downloadbbiy-bb75e40de92fb7e0589410b67e21087f27f34f45.tar.gz
bbiy-bb75e40de92fb7e0589410b67e21087f27f34f45.zip
Movement bug with two+ pushable entities
Diffstat (limited to 'src/systems/physics.js')
-rw-r--r--src/systems/physics.js3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/systems/physics.js b/src/systems/physics.js
index 0da8b9d..a49edca 100644
--- a/src/systems/physics.js
+++ b/src/systems/physics.js
@@ -6,8 +6,7 @@ game.system.Physics = () => {
const {dx, dy} = entity.components.momentum;
entity.components.position.x += dx * elapsedTime;
entity.components.position.y += dy * elapsedTime;
- entity.components.position.x = Math.max(0, Math.min(game.canvas.width - entity.components.appearance.width, entity.components.position.x));
- entity.components.position.y = Math.max(0, Math.min(game.canvas.height - entity.components.appearance.height, entity.components.position.y));
+ entity.components.position = clamp(entity.components.position, game.canvas.width - entity.components.appearance.width, game.canvas.height - entity.components.appearance.height);
}
}
}