summaryrefslogtreecommitdiff
path: root/logic/controller.lua
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-03-11 09:49:34 +0800
committerEltrac <hi@guhub.cn>2025-03-11 09:49:34 +0800
commit3a358884ca62ae4d0ceb79faccb91059702ba22b (patch)
treef7dd0b92aa6aa2d7d5afcfa2f934e569bf524b8b /logic/controller.lua
parent07f29613149ebe25e5d2e8b24b95d63eedfaa314 (diff)
Revert "chore: allow direction keys to move"
This reverts commit 843ace158173805c6273a2d09bd3d61088492f80.
Diffstat (limited to 'logic/controller.lua')
-rw-r--r--logic/controller.lua28
1 files changed, 12 insertions, 16 deletions
diff --git a/logic/controller.lua b/logic/controller.lua
index 8ce8cec..00149b5 100644
--- a/logic/controller.lua
+++ b/logic/controller.lua
@@ -16,29 +16,25 @@ end
local function playerPressKeysToMoves(dt)
local moveDirections = {
- { keys = {"d","right"}, axis = "x", dir = Direction.RIGHT, delta = 1 },
- { keys = {"a","left"}, axis = "x", dir = Direction.LEFT, delta = -1 },
- { keys = {"w","up"}, axis = "y", dir = Direction.TOP, delta = -1 },
- { keys = {"s","down"}, axis = "y", dir = Direction.BOTTOM, delta = 1 }
+ { key = "d", axis = "x", dir = Direction.RIGHT, delta = 1 },
+ { key = "a", axis = "x", dir = Direction.LEFT, delta = -1 },
+ { key = "w", axis = "y", dir = Direction.TOP, delta = -1 },
+ { key = "s", axis = "y", dir = Direction.BOTTOM, delta = 1 }
}
local keydown = love.keyboard.isDown
for _, move in ipairs(moveDirections) do
local dv = G.player.speed * dt * move.delta
- for _, key in ipairs(move.keys) do
- if keydown(key) then
- G.player.facing = move.dir
- G.player.moving = true
-
- local delta = G.player.speed * dt * move.delta
- if utils.isBlocked(G.player.body, G.player.x, G.player.y, move.dir, move.axis, dv) then
- delta = 0
- end
- G.player[move.axis] = G.player[move.axis] + delta
-
- break
+ if keydown(move.key) then
+ G.player.facing = move.dir
+ G.player.moving = true
+
+ local delta = G.player.speed * dt * move.delta
+ if utils.isBlocked(G.player.body, G.player.x, G.player.y, move.dir, move.axis, dv) then
+ delta = 0
end
+ G.player[move.axis] = G.player[move.axis] + delta
end
end