From 14ddb31441e35dce7425385948a9ee63b262cece Mon Sep 17 00:00:00 2001 From: Logan Hunt Date: Mon, 4 Apr 2022 15:30:56 -0600 Subject: [PATCH] Fix moveable components when multiple moveable entities --- src/game.js | 3 +-- src/systems/keyboardInput.js | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/game.js b/src/game.js index 7301f73..69a91ce 100644 --- a/src/game.js +++ b/src/game.js @@ -29,14 +29,13 @@ game.initialize = () => { Array(10).fill(null).forEach((_, i) => { const bigBlue = game.createBigBlue(); bigBlue.addComponent(game.components.GridPosition({x: Math.floor(Math.random() * 15), y: Math.floor(Math.random() * 13)})); - bigBlue.addComponent(game.components.Pushable()); + bigBlue.addComponent(game.components.Controllable({controls: ['left', 'right', 'up', 'down']})); game.entities[bigBlue.id] = bigBlue; }); game.rock = game.createRock(); game.rock.addComponent(game.components.Position({x: 200, y: 200})); game.rock.addComponent(game.components.GridPosition({x: 0, y: 0})); - game.rock.addComponent(game.components.Controllable({controls: ['left', 'right', 'up', 'down']})); game.rock.addComponent(game.components.Pushable()); game.entities[game.rock.id] = game.rock; diff --git a/src/systems/keyboardInput.js b/src/systems/keyboardInput.js index ff2211c..24fd076 100644 --- a/src/systems/keyboardInput.js +++ b/src/systems/keyboardInput.js @@ -21,9 +21,9 @@ game.system.KeyboardInput = () => { entity.addComponent(game.components.Momentum({ dx: 0, dy: 1 })); } - Object.keys(keys).map((key) => delete keys[key]); } } + Object.keys(keys).map((key) => delete keys[key]); }; window.addEventListener("keydown", keyPress); return { keys, update };