summaryrefslogtreecommitdiff
path: root/src/systems/physics.js
diff options
context:
space:
mode:
authorLogan Hunt <loganhunt@simponic.xyz>2022-04-02 16:04:13 -0600
committerLogan Hunt <loganhunt@simponic.xyz>2022-04-02 16:04:13 -0600
commit5a55b5fa0c678ff03842d2adec8543e754546718 (patch)
tree4f615829acc10045d81a9d553c757a14792bf81a /src/systems/physics.js
parent4d34b0b4b890e957030fbf6e3c8e1d4a02d2a627 (diff)
downloadbbiy-5a55b5fa0c678ff03842d2adec8543e754546718.tar.gz
bbiy-5a55b5fa0c678ff03842d2adec8543e754546718.zip
Grid system & simple physics
Diffstat (limited to 'src/systems/physics.js')
-rw-r--r--src/systems/physics.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/systems/physics.js b/src/systems/physics.js
new file mode 100644
index 0000000..c9b6cf7
--- /dev/null
+++ b/src/systems/physics.js
@@ -0,0 +1,13 @@
+game.system.Physics = () => {
+ const update = (elapsedTime) => {
+ for (let id in game.entities) {
+ const entity = game.entities[id];
+ if (entity.hasComponent("momentum")) {
+ const {dx, dy} = entity.components.momentum;
+ entity.components.position.x += dx * elapsedTime;
+ entity.components.position.y += dy * elapsedTime;
+ }
+ }
+ }
+ return { update };
+} \ No newline at end of file