diff options
Diffstat (limited to 'client/src/logic/movement.ts')
-rw-r--r-- | client/src/logic/movement.ts | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/client/src/logic/movement.ts b/client/src/logic/movement.ts index 40cfc3e..f03008b 100644 --- a/client/src/logic/movement.ts +++ b/client/src/logic/movement.ts @@ -1,5 +1,5 @@ import { getMap } from "../map.js" -import { Vec2, Map, Rotation, Key, Player, GameState } from "../types.js" +import { Vec2, Map, Rotation, Key, Player, GameState, Tile } from "../types.js" const MOVE_SPEED = .1 @@ -20,7 +20,7 @@ const getTile = ( ): number => { let x = Math.round(pos.x + ox) let y = Math.round(pos.y + oy) - if (x < 0 || x >= map.width || y < 0 || y >= map.height) return 1 + if (x < 0 || x >= map.width || y < 0 || y >= map.height) return Tile.WALL return map.data[y * map.width + x] } @@ -73,13 +73,11 @@ const incrementPos = ( pos.x -= speed break case Rotation.EAST: - pos.y += speed + pos.x += speed break } } -let i = 0 - const updateMovementForPlayer = ( map: Map, player: Player, @@ -91,7 +89,7 @@ const updateMovementForPlayer = ( let currentPosition = player.pos let turningFrontTile = getTileFrontWithRot(map, currentPosition, inputRot) - if (turningFrontTile == 1 || turningFrontTile == 2) { + if (turningFrontTile == Tile.WALL || turningFrontTile == Tile.GHOST_WALL) { inputRot = Rotation.NOTHING } @@ -109,7 +107,7 @@ const updateMovementForPlayer = ( incrementPos(movePos, moveRot, MOVE_SPEED) let frontTile = getTileFrontWithRot(map, currentPosition, moveRot) - if (frontTile != 1 && frontTile != 2) { + if (frontTile != Tile.WALL && frontTile != Tile.GHOST_WALL) { player.pos = movePos player.moving = true } else { |