From eaff86546eca516d51c27eb9d63ea33a96576e90 Mon Sep 17 00:00:00 2001 From: Mike Vink Date: Fri, 23 Jul 2021 13:03:19 +0200 Subject: info(): moved a bunch of files --- client/src/akkamon/render/GridControls.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 client/src/akkamon/render/GridControls.ts (limited to 'client/src/akkamon/render/GridControls.ts') 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); + } + } + + +} -- cgit v1.2.3