mirror of
https://github.com/LDDestroier/CC/
synced 2025-01-05 15:00:28 +00:00
Update tron
This commit is contained in:
parent
a4c810815b
commit
955797c32c
18
tron
18
tron
@ -52,6 +52,7 @@ local scrollAdjX = 0
|
|||||||
local scrollAdjY = 0
|
local scrollAdjY = 0
|
||||||
|
|
||||||
local lockInput = false
|
local lockInput = false
|
||||||
|
local gameDelay = 0.05
|
||||||
local player
|
local player
|
||||||
|
|
||||||
local resetPlayers = function()
|
local resetPlayers = function()
|
||||||
@ -516,14 +517,11 @@ local cleanExit = function()
|
|||||||
term.setTextColor(colors.white)
|
term.setTextColor(colors.white)
|
||||||
term.clear()
|
term.clear()
|
||||||
term.setCursorPos(1,1)
|
term.setCursorPos(1,1)
|
||||||
print("Buh-bye.")
|
print("Thanks for playing!")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- test background drawing
|
|
||||||
|
|
||||||
local getInput = function()
|
local getInput = function()
|
||||||
local evt
|
local evt
|
||||||
-- os.pullEvent("new_game")
|
|
||||||
while true do
|
while true do
|
||||||
evt = {os.pullEvent()}
|
evt = {os.pullEvent()}
|
||||||
if lockInput then
|
if lockInput then
|
||||||
@ -538,12 +536,12 @@ local getInput = function()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scrollToPosition = function(x, y)
|
local scrollToPosition = function(x, y)
|
||||||
for i = 1, 16 do
|
for i = 1, 16 do
|
||||||
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(0.05)
|
sleep(gameDelay)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -567,7 +565,7 @@ local gridDemo = function()
|
|||||||
end
|
end
|
||||||
drawGrid(scrollX, scrollY)
|
drawGrid(scrollX, scrollY)
|
||||||
ageTrails()
|
ageTrails()
|
||||||
sleep(0.05)
|
sleep(gameDelay)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -577,7 +575,8 @@ local sendInfo = function(gameID)
|
|||||||
gameID = gameID,
|
gameID = 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
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -698,7 +697,7 @@ local game = function()
|
|||||||
scrollY = p.y - math.floor(scr_y / 2)
|
scrollY = p.y - math.floor(scr_y / 2)
|
||||||
|
|
||||||
render()
|
render()
|
||||||
sleep(0.05)
|
sleep(gameDelay)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -734,6 +733,7 @@ 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
|
||||||
|
Loading…
Reference in New Issue
Block a user