summaryrefslogtreecommitdiff
path: root/src/engine/systems/Input.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/systems/Input.ts')
-rw-r--r--src/engine/systems/Input.ts28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/engine/systems/Input.ts b/src/engine/systems/Input.ts
index 3da018d..8900f4e 100644
--- a/src/engine/systems/Input.ts
+++ b/src/engine/systems/Input.ts
@@ -1,10 +1,11 @@
-import { SystemNames, System } from ".";
+import { Grid as GridSystem, SystemNames, System } from ".";
import { Game } from "..";
import { ComponentNames, Grid, Interactable } from "../components";
import { Control } from "../components/Control";
import { Action, KeyConstants } from "../config";
-import { Entity } from "../entities";
+import { Entity, Particles } from "../entities";
import { Coord2D, Direction } from "../interfaces";
+import { colors } from "../utils";
export class Input extends System {
private keys: Set<string>;
@@ -31,7 +32,7 @@ export class Input extends System {
public update(_dt: number, game: Game) {
game.forEachEntityWithComponent(ComponentNames.Control, (entity) =>
- this.handleMovement(entity),
+ this.handleMovement(entity, game),
);
game.forEachEntityWithComponent(ComponentNames.Interactable, (entity) =>
this.handleInteraction(entity),
@@ -57,7 +58,7 @@ export class Input extends System {
);
}
- public handleMovement(entity: Entity) {
+ public handleMovement(entity: Entity, game: Game) {
const controlComponent = entity.getComponent<Control>(
ComponentNames.Control,
);
@@ -103,6 +104,25 @@ export class Input extends System {
);
}
+ if (moveUp || moveLeft || moveRight || moveDown) {
+ const gridPosition = gridComponent.gridPosition;
+ const gridSystem = game.getSystem<GridSystem>(SystemNames.Grid);
+ const particles = new Particles({
+ center: gridSystem.gridToScreenPosition(gridPosition),
+ particleCount: 5,
+ particleShape: "circle",
+ particleMeanSpeed: 0.05,
+ particleSpeedVariance: 0.005,
+ particleMeanLife: 120,
+ particleMeanSize: 5,
+ particleSizeVariance: 2,
+ particleLifeVariance: 30,
+ particleColors: [colors.gray, colors.darkGray],
+ });
+
+ game.addEntity(particles);
+ }
+
entity.addComponent(gridComponent);
}