diff options
author | phat_sumo <ethanjpayne1@gmail.com> | 2022-04-02 18:48:00 -0600 |
---|---|---|
committer | phat_sumo <ethanjpayne1@gmail.com> | 2022-04-02 18:48:00 -0600 |
commit | cf4dbf91ddb980c051ee2905367143d433c376a5 (patch) | |
tree | 9b4697850979774ba8056ac792230bfb7b8a2073 /src/systems | |
parent | aef3c05bc7f3feba7832078aa1cb4bd96c52c1dd (diff) | |
download | bbiy-cf4dbf91ddb980c051ee2905367143d433c376a5.tar.gz bbiy-cf4dbf91ddb980c051ee2905367143d433c376a5.zip |
the mess that is pushable
Diffstat (limited to 'src/systems')
-rw-r--r-- | src/systems/gridSystem.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/systems/gridSystem.js b/src/systems/gridSystem.js index 05ce17e..c80fe1a 100644 --- a/src/systems/gridSystem.js +++ b/src/systems/gridSystem.js @@ -52,6 +52,16 @@ game.system.GridSystem = ({ xDim, yDim, canvasWidth, canvasHeight }) => { }); // TODO: Loop in momentum direction until we find an entity that does not have "push" component + const proposed = {x: entity.components.gridPosition.x + momentumVector.dx, y: entity.components.gridPosition.y + momentumVector.dy} + + const entitiesInCell = entitiesGrid[proposed.x][proposed.y]; + + for (let id in entitiesInCell) { + if (entitiesInCell[id].hasComponent("pushable")) { + entitiesInCell[id].addComponent(game.components.Momentum({...momentumVector})); + } + } + entity.components.gridPosition.x = entity.components.gridPosition.x + momentumVector.dx; entity.components.gridPosition.y = entity.components.gridPosition.y + momentumVector.dy; @@ -70,4 +80,4 @@ game.system.GridSystem = ({ xDim, yDim, canvasWidth, canvasHeight }) => { }; return { entitiesGrid, gameCoordsToGrid, gridCoordsToGame, update, gridWidth, gridHeight }; -};
\ No newline at end of file +}; |