From 9200f46f71f65acd22f15192be374caa8626906d Mon Sep 17 00:00:00 2001 From: LDDestroier Date: Wed, 14 Nov 2018 16:09:32 -0500 Subject: [PATCH] Update tron --- tron | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tron b/tron index cb0c1b9..53451bd 100644 --- a/tron +++ b/tron @@ -36,14 +36,15 @@ local nou = 2 local keysDown = {} local netKeysDown = {} +-- the scrolling of the screen local scrollX = 0 local scrollY = 0 +-- used when panning with WASD local scrollAdjX = 0 local scrollAdjY = 0 local lockInput = false - local player local resetPlayers = function() @@ -570,6 +571,11 @@ local sendInfo = function(gameID) }) end +local waitForKey = function(time) + sleep(time or 0.1) + os.pullEvent("char") +end + local deadAnimation = function(doSend) for k,v in pairs(deadGuys) do player[k].char = "X" @@ -584,19 +590,19 @@ local deadAnimation = function(doSend) scrollToPosition(player[nou].x, player[nou].y) scrollToPosition(player[you].x, player[you].y) drawImage(images.tie, math.floor(scr_x / 2 - images.tie.x / 2), math.floor(scr_y / 2 - images.tie.y / 2)) - sleep(1.5) + waitForKey(1) return "end" else if deadGuys[you] then scrollX, scrollY = player[nou].x - scr_x / 2, player[nou].y - scr_y / 2 scrollToPosition(player[you].x, player[you].y) drawImage(images.lose, math.floor(scr_x / 2 - images.lose.x / 2), math.floor(scr_y / 2 - images.lose.y / 2)) - sleep(1.5) + waitForKey(1) return "end" elseif deadGuys[nou] then scrollToPosition(player[nou].x, player[nou].y) drawImage(images.win, math.floor(scr_x / 2 - images.win.x / 2), math.floor(scr_y / 2 - images.win.y / 2)) - sleep(1.5) + waitForKey(1) return "end" end end @@ -753,4 +759,4 @@ while true do elseif decision == "exit" then return cleanExit() end -end \ No newline at end of file +end