Fix moveable components when multiple moveable entities
This commit is contained in:
parent
8cdffd7915
commit
14ddb31441
@ -29,14 +29,13 @@ game.initialize = () => {
|
|||||||
Array(10).fill(null).forEach((_, i) => {
|
Array(10).fill(null).forEach((_, i) => {
|
||||||
const bigBlue = game.createBigBlue();
|
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.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.entities[bigBlue.id] = bigBlue;
|
||||||
});
|
});
|
||||||
|
|
||||||
game.rock = game.createRock();
|
game.rock = game.createRock();
|
||||||
game.rock.addComponent(game.components.Position({x: 200, y: 200}));
|
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.GridPosition({x: 0, y: 0}));
|
||||||
game.rock.addComponent(game.components.Controllable({controls: ['left', 'right', 'up', 'down']}));
|
|
||||||
game.rock.addComponent(game.components.Pushable());
|
game.rock.addComponent(game.components.Pushable());
|
||||||
game.entities[game.rock.id] = game.rock;
|
game.entities[game.rock.id] = game.rock;
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@ game.system.KeyboardInput = () => {
|
|||||||
entity.addComponent(game.components.Momentum({ dx: 0, dy: 1 }));
|
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);
|
window.addEventListener("keydown", keyPress);
|
||||||
return { keys, update };
|
return { keys, update };
|
||||||
|
Loading…
Reference in New Issue
Block a user