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

Update tron

This commit is contained in:
LDDestroier 2018-11-15 00:29:31 -05:00 committed by GitHub
parent f2bc46852a
commit 05cf9c55ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

19
tron
View File

@ -669,22 +669,22 @@ local moveTick = function(doSend)
return deadAnimation(doSend) return deadAnimation(doSend)
end end
local setDirection = function(keylist, p) local setDirection = function(keylist, p, checkDir)
p.putTrail = not keylist[control.release] p.putTrail = not keylist[control.release]
if keylist[control.left] and p.direction ~= 0 then if keylist[control.left] and (checkDir or p.direction) ~= 0 then
p.direction = 2 p.direction = 2
elseif keylist[control.right] and p.direction ~= 2 then elseif keylist[control.right] and (checkDir or p.direction) ~= 2 then
p.direction = 0 p.direction = 0
end end
if keylist[control.up] and p.direction ~= 1 then if keylist[control.up] and (checkDir or p.direction) ~= 1 then
p.direction = -1 p.direction = -1
elseif keylist[control.down] and p.direction ~= -1 then elseif keylist[control.down] and (checkDir or p.direction) ~= -1 then
p.direction = 1 p.direction = 1
end end
end end
-- to counter P2's ability to turn twice in one tick -- to counter P2's ability to turn twice in one tick
local inMidTurn = false local dlDirection
local game = function() local game = function()
local outcome local outcome
@ -697,9 +697,8 @@ local game = function()
if isHost then if isHost then
setDirection(keysDown, p) setDirection(keysDown, p)
setDirection(netKeysDown, np) setDirection(netKeysDown, np)
elseif not inMidTurn then else then
setDirection(keysDown, p) setDirection(keysDown, p, dlDirection)
inMidTurn = true
end end
if keysDown[control.lookLeft] then if keysDown[control.lookLeft] then
@ -769,9 +768,9 @@ local networking = function()
elseif msg.gameID == gamename then elseif msg.gameID == gamename then
if not isHost then if not isHost then
player = msg.player player = msg.player
dlDirection = player[you].direction
trail = msg.trail trail = msg.trail
deadGuys = msg.deadGuys deadGuys = msg.deadGuys
inMidTurn = false
elseif type(msg.keysDown) == "table" then elseif type(msg.keysDown) == "table" then
netKeysDown = msg.keysDown netKeysDown = msg.keysDown
end end