summaryrefslogtreecommitdiff
path: root/client/src/akkamon/render/GridControls.ts
diff options
context:
space:
mode:
authorMike Vink <mike1994vink@gmail.com>2021-07-23 13:03:19 +0200
committerMike Vink <mike1994vink@gmail.com>2021-07-23 13:03:19 +0200
commiteaff86546eca516d51c27eb9d63ea33a96576e90 (patch)
tree6af16df4b45b2944c41adf865905240da75612c7 /client/src/akkamon/render/GridControls.ts
parent0148ea0de6aa06306fd973694e313b98a777c136 (diff)
info(): moved a bunch of files
Diffstat (limited to 'client/src/akkamon/render/GridControls.ts')
-rw-r--r--client/src/akkamon/render/GridControls.ts27
1 files changed, 27 insertions, 0 deletions
diff --git a/client/src/akkamon/render/GridControls.ts b/client/src/akkamon/render/GridControls.ts
new file mode 100644
index 0000000..d7feef2
--- /dev/null
+++ b/client/src/akkamon/render/GridControls.ts
@@ -0,0 +1,27 @@
+import { Direction } from './Direction';
+import type { GridPhysics } from './GridPhysics';
+
+export class GridControls {
+ private cursors: Phaser.Types.Input.Keyboard.CursorKeys;
+
+ constructor(
+ private input: Phaser.Input.InputPlugin,
+ private gridPhysics: GridPhysics,
+ ) {
+ this.cursors = this.input.keyboard.createCursorKeys();
+ }
+
+ update() {
+ if (this.cursors.left.isDown) {
+ this.gridPhysics.movePlayerSprite(Direction.LEFT);
+ } else if (this.cursors.right.isDown) {
+ this.gridPhysics.movePlayerSprite(Direction.RIGHT);
+ } else if (this.cursors.up.isDown) {
+ this.gridPhysics.movePlayerSprite(Direction.UP);
+ } else if (this.cursors.down.isDown) {
+ this.gridPhysics.movePlayerSprite(Direction.DOWN);
+ }
+ }
+
+
+}