summaryrefslogtreecommitdiff
path: root/client/src/logic/movement.ts
diff options
context:
space:
mode:
authorTyler Murphy <tylerm@tylerm.dev>2023-06-17 01:18:16 -0400
committerTyler Murphy <tylerm@tylerm.dev>2023-06-17 01:18:16 -0400
commit113c6d105a0b06603388e5e0ded90ed169ae0c50 (patch)
tree70af321cdce86a331141e437f6abae3c1cefd74a /client/src/logic/movement.ts
parentts (diff)
downloadtuxman-113c6d105a0b06603388e5e0ded90ed169ae0c50.tar.gz
tuxman-113c6d105a0b06603388e5e0ded90ed169ae0c50.tar.bz2
tuxman-113c6d105a0b06603388e5e0ded90ed169ae0c50.zip
map editor
Diffstat (limited to 'client/src/logic/movement.ts')
-rw-r--r--client/src/logic/movement.ts12
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 {