From c087bad683e1e6e0a0f7e770c88f0847e8c15732 Mon Sep 17 00:00:00 2001 From: LDDestroier Date: Tue, 13 Nov 2018 20:34:28 -0500 Subject: [PATCH] Update tron --- tron | 49 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/tron b/tron index f6dd87f..65ba9c5 100644 --- a/tron +++ b/tron @@ -25,7 +25,7 @@ local player local resetPlayers = function() player = { [1] = { - x = 2, + x = -2, y = -5, direction = -1, char = "@", @@ -44,7 +44,7 @@ local resetPlayers = function() putTrail = true }, [2] = { - x = -2, + x = 2, y = -5, direction = -1, char = "@", @@ -117,6 +117,7 @@ local toblit = { } local you = 1 +local nou = 2 local control = { up = keys.up, @@ -397,6 +398,9 @@ local gridDemo = function() if keysDown[keys.down] then scrollY = scrollY + 1 end + if keysDown[keys.q] then + return "end" + end drawGrid(scrollX, scrollY) ageTrails() sleep(0.05) @@ -405,6 +409,7 @@ end local moveTick = function() local p + local deadGuys = {} for i = 1, #player do p = player[i] if not p.dead then @@ -412,22 +417,9 @@ local moveTick = function() p.y = p.y + math.floor(math.sin(math.rad(p.direction * 90))) if getTrail(p.x, p.y) or (p.x == grid.x1 or p.x == grid.x2 or p.y == grid.y1 or p.y == grid.y2) then p.dead = true + deadGuys[i] = true p.char = "X" lockInput = true - term.setTextColor(colors.white) - if i ~= you then - scrollToPosition(p.x, p.y) - term.setCursorPos(1,scr_y) - term.write("You're winner!") - sleep(1.5) - return "end" - else - sleep(0.5) - term.setCursorPos(1,scr_y) - term.write("You're loser.") - sleep(1.5) - return "end" - end else if p.putTrail then putTrail(p) @@ -435,6 +427,31 @@ local moveTick = function() end end end + if deadGuys[you] or deadGuys[nou] then + term.setTextColor(colors.white) + if deadGuys[you] and deadGuys[nou] then + scrollToPosition(player[nou].x, player[nou].y) + scrollToPosition(player[you].x, player[you].y) + term.setCursorPos(1,scr_y) + term.write("It's a tie!") + sleep(1.5) + return "end" + else + if deadGuys[you] then + sleep(0.5) + term.setCursorPos(1,scr_y) + term.write("You're loser.") + sleep(1.5) + return "end" + elseif deadGuys[nou] then + scrollToPosition(player[nou].x, player[nou].y) + term.setCursorPos(1,scr_y) + term.write("You're winner!") + sleep(1.5) + return "end" + end + end + end ageTrails() end