Move key config to dictionaries
This commit is contained in:
parent
6617a243ce
commit
d79fa1abf4
|
@ -21,6 +21,18 @@ local move_repeat_counter = nil
|
||||||
local gamemodes = {normal = 0, won = 1}
|
local gamemodes = {normal = 0, won = 1}
|
||||||
local game_mode = gamemodes.normal
|
local game_mode = gamemodes.normal
|
||||||
|
|
||||||
|
local direction_keys = {}
|
||||||
|
direction_keys['i'] = directions.up
|
||||||
|
direction_keys['u'] = directions.upleft
|
||||||
|
direction_keys['j'] = directions.left
|
||||||
|
direction_keys['m'] = directions.downleft
|
||||||
|
direction_keys['k'] = directions.down
|
||||||
|
direction_keys['.'] = directions.downright
|
||||||
|
direction_keys['l'] = directions.right
|
||||||
|
direction_keys['o'] = directions.upright
|
||||||
|
|
||||||
|
local control_keys = {quit = 'q', restart = 'r'}
|
||||||
|
|
||||||
-- ------------------------------------------------------------------
|
-- ------------------------------------------------------------------
|
||||||
-- Cavern generation
|
-- Cavern generation
|
||||||
-- ------------------------------------------------------------------
|
-- ------------------------------------------------------------------
|
||||||
|
@ -601,26 +613,13 @@ end
|
||||||
|
|
||||||
function love.keypressed(key)
|
function love.keypressed(key)
|
||||||
last_key_pressed = key
|
last_key_pressed = key
|
||||||
if key == 'r' then
|
|
||||||
newGame()
|
if key == control_keys.quit then
|
||||||
elseif key == 'i' then
|
|
||||||
step(directions.up)
|
|
||||||
elseif key == 'j' then
|
|
||||||
step(directions.left)
|
|
||||||
elseif key == 'k' then
|
|
||||||
step(directions.down)
|
|
||||||
elseif key == 'l' then
|
|
||||||
step(directions.right)
|
|
||||||
elseif key == 'u' then
|
|
||||||
step(directions.upleft)
|
|
||||||
elseif key == 'm' then
|
|
||||||
step(directions.downleft)
|
|
||||||
elseif key == '.' then
|
|
||||||
step(directions.downright)
|
|
||||||
elseif key == 'o' then
|
|
||||||
step(directions.upright)
|
|
||||||
elseif key == 'q' then
|
|
||||||
love.event.quit()
|
love.event.quit()
|
||||||
|
elseif key == control_keys.restart then
|
||||||
|
newGame()
|
||||||
|
elseif direction_keys[key] ~= nil then
|
||||||
|
step(direction_keys[key])
|
||||||
elseif key == 'printscreen' then
|
elseif key == 'printscreen' then
|
||||||
debug = true
|
debug = true
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue