1
0
mirror of https://github.com/LDDestroier/CC/ synced 2024-12-14 12:10:29 +00:00

Added countdown

This commit is contained in:
LDDestroier 2018-11-14 19:28:01 -05:00 committed by GitHub
parent ee107a46b9
commit fffd4095aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

27
tron
View File

@ -475,11 +475,37 @@ local pleaseWait = function()
periods = (periods % maxPeriods) + 1 periods = (periods % maxPeriods) + 1
term.clearLine() term.clearLine()
elseif evt[1] == "new_game" then elseif evt[1] == "new_game" then
sleep(0.1)
return evt[2] return evt[2]
end end
end end
end end
local startCountdown = function()
local cName = "PLAYER " .. you
local col = colors.white
for k,v in pairs(colors) do
if player[you].color[1] == v then
cName = k:upper()
col = v
break
end
end
local cMessage = "You are "
for i = 3, 1 do
render()
term.setCursorPos(math.floor(scr_x / 2 - (#cMessage + #cName) / 2), math.floor(scr_y / 2))
term.setTextColor(colors.white)
term.write(cMessage)
term.setTextColor(col)
term.write(cName)
term.setTextColor(colors.white)
term.setCursorPos(math.floor(scr_x / 2 - 2), math.floor(scr_y / 2) + 2)
term.write(i .. "...")
sleep(1)
end
end
local makeMenu = function(x, y, options) local makeMenu = function(x, y, options)
local cpos = 1 local cpos = 1
local cursor = "> " local cursor = "> "
@ -804,6 +830,7 @@ while true do
grid = initGrid grid = initGrid
}) })
parallel.waitForAny(pleaseWait, networking) parallel.waitForAny(pleaseWait, networking)
startCountdown()
parallel.waitForAny(getInput, game, networking) parallel.waitForAny(getInput, game, networking)
elseif decision == "help" then elseif decision == "help" then
helpScreen() helpScreen()