mirror of
https://github.com/LDDestroier/CC/
synced 2025-01-05 15:00:28 +00:00
Update tron
This commit is contained in:
parent
955797c32c
commit
b90780c461
46
tron
46
tron
@ -25,7 +25,23 @@ local isHost
|
|||||||
|
|
||||||
local waitingForGame = true
|
local waitingForGame = true
|
||||||
|
|
||||||
local grid = {
|
local deepCopy
|
||||||
|
deepCopy = function(tbl, ...)
|
||||||
|
local output = {}
|
||||||
|
for k,v in pairs(tbl) do
|
||||||
|
if type(v) == "table" then
|
||||||
|
output[k] = deepCopy(v)
|
||||||
|
else
|
||||||
|
output[k] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for i = 1, #arg do
|
||||||
|
output[#output+1] = arg[i]
|
||||||
|
end
|
||||||
|
return output
|
||||||
|
end
|
||||||
|
|
||||||
|
local gridInit = {
|
||||||
x1 = -80,
|
x1 = -80,
|
||||||
y1 = -80,
|
y1 = -80,
|
||||||
x2 = 80,
|
x2 = 80,
|
||||||
@ -36,6 +52,7 @@ local grid = {
|
|||||||
backcol = "7",
|
backcol = "7",
|
||||||
edgecol = "0"
|
edgecol = "0"
|
||||||
}
|
}
|
||||||
|
grid = deepCopy(gridInit)
|
||||||
|
|
||||||
local you = 1
|
local you = 1
|
||||||
local nou = 2
|
local nou = 2
|
||||||
@ -52,7 +69,7 @@ local scrollAdjX = 0
|
|||||||
local scrollAdjY = 0
|
local scrollAdjY = 0
|
||||||
|
|
||||||
local lockInput = false
|
local lockInput = false
|
||||||
local gameDelay = 0.05
|
local gameDelayInit = 0.05
|
||||||
local player
|
local player
|
||||||
|
|
||||||
local resetPlayers = function()
|
local resetPlayers = function()
|
||||||
@ -444,22 +461,6 @@ local pleaseWait = function()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local deepCopy
|
|
||||||
deepCopy = function(tbl, ...)
|
|
||||||
local output = {}
|
|
||||||
for k,v in pairs(tbl) do
|
|
||||||
if type(v) == "table" then
|
|
||||||
output[k] = deepCopy(v)
|
|
||||||
else
|
|
||||||
output[k] = v
|
|
||||||
end
|
|
||||||
end
|
|
||||||
for i = 1, #arg do
|
|
||||||
output[#output+1] = arg[i]
|
|
||||||
end
|
|
||||||
return output
|
|
||||||
end
|
|
||||||
|
|
||||||
local makeMenu = function(x, y, options)
|
local makeMenu = function(x, y, options)
|
||||||
local cpos = 1
|
local cpos = 1
|
||||||
local cursor = "> "
|
local cursor = "> "
|
||||||
@ -541,7 +542,7 @@ local scrollToPosition = function(x, y)
|
|||||||
scrollX = (scrollX + x - (scr_x/2)) / 2
|
scrollX = (scrollX + x - (scr_x/2)) / 2
|
||||||
scrollY = (scrollY + y - (scr_y/2)) / 2
|
scrollY = (scrollY + y - (scr_y/2)) / 2
|
||||||
render()
|
render()
|
||||||
sleep(gameDelay)
|
sleep(0.05)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -576,7 +577,8 @@ local sendInfo = function(gameID)
|
|||||||
keysDown = keysDown,
|
keysDown = keysDown,
|
||||||
trail = isHost and trail or nil,
|
trail = isHost and trail or nil,
|
||||||
deadGuys = isHost and deadGuys or {},
|
deadGuys = isHost and deadGuys or {},
|
||||||
gameDelay = gameDelay
|
gameDelay = (gameDelay or gameDelayInit),
|
||||||
|
grid = grid
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -715,6 +717,8 @@ local networking = function()
|
|||||||
if msg.new < os.time() then
|
if msg.new < os.time() then
|
||||||
gamename = msg.gameID
|
gamename = msg.gameID
|
||||||
isHost = false
|
isHost = false
|
||||||
|
gameDelay = tonumber(msg.gameDelay) or 0.05
|
||||||
|
grid = deepCopy(msg.grid or gridInit)
|
||||||
else
|
else
|
||||||
you, nou = nou, you
|
you, nou = nou, you
|
||||||
isHost = true
|
isHost = true
|
||||||
@ -733,7 +737,6 @@ local networking = function()
|
|||||||
player = msg.player
|
player = msg.player
|
||||||
trail = msg.trail
|
trail = msg.trail
|
||||||
deadGuys = msg.deadGuys
|
deadGuys = msg.deadGuys
|
||||||
gameDelay = tonumber(msg.gameDelay) or 0.05
|
|
||||||
elseif type(msg.keysDown) == "table" then
|
elseif type(msg.keysDown) == "table" then
|
||||||
netKeysDown = msg.keysDown
|
netKeysDown = msg.keysDown
|
||||||
end
|
end
|
||||||
@ -766,6 +769,7 @@ while true do
|
|||||||
if decision == "start" then
|
if decision == "start" then
|
||||||
trail = {}
|
trail = {}
|
||||||
deadGuys = {}
|
deadGuys = {}
|
||||||
|
gameDelay = gameDelayInit
|
||||||
resetPlayers()
|
resetPlayers()
|
||||||
you, nou = 1, 2
|
you, nou = 1, 2
|
||||||
gamename = ""
|
gamename = ""
|
||||||
|
Loading…
Reference in New Issue
Block a user