From dc485a7c5f514fa7b6ffac7e02723109af2ee6ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Fri, 28 Jun 2019 20:31:03 +0300 Subject: [PATCH] Impoved movement --- bundle/main.lua | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/bundle/main.lua b/bundle/main.lua index ed0cd63..ce8431e 100644 --- a/bundle/main.lua +++ b/bundle/main.lua @@ -181,7 +181,13 @@ function movePlayer(direction) elseif direction == directions.right then dx = 1 elseif direction == directions.upleft then - if player_direction == directions.down then + if player_direction == directions.up then + dx = -1 + new_direction = directions.left + elseif player_direction == directions.left then + dy = -1 + new_direction = directions.up + elseif player_direction == directions.down then -- ## ## -- x# xo# -- #o# # # @@ -203,6 +209,12 @@ function movePlayer(direction) -- ## ## dy = 1 new_direction = directions.right + elseif player_direction == directions.left then + dy = 1 + new_direction = directions.down + elseif player_direction == directions.down then + dx = -1 + new_direction = directions.left elseif player_direction == directions.right then -- ## ## -- #xo #o @@ -225,22 +237,34 @@ function movePlayer(direction) -- # # #x# dx = 1 new_direction = directions.up + elseif player_direction == directions.down then + dx = 1 + new_direction = directions.right + elseif player_direction == directions.right then + dy = 1 + new_direction = directions.down else new_direction = player_direction end elseif direction == directions.upright then - if player_direction == directions.down then - -- ## ## - -- #x #ox - -- #o# # # - dy = -1 - new_direction = directions.left + if player_direction == directions.up then + dx = 1 + new_direction = directions.right elseif player_direction == directions.left then -- # # #x# -- ox# o# -- ## ## dx = 1 new_direction = directions.down + elseif player_direction == directions.down then + -- ## ## + -- #x #ox + -- #o# # # + dy = -1 + new_direction = directions.left + elseif player_direction == directions.right then + dy = -1 + new_direction = directions.up else new_direction = player_direction end