diff options
Diffstat (limited to 'src/systems/gridSystem.js')
-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 +}; |