mirror of
https://github.com/LDDestroier/CC/
synced 2025-02-02 04:09:09 +00:00
Fixed multiplayer graphical bug
This commit is contained in:
parent
0e225b21f5
commit
d5fce05ffa
40
ldris.lua
40
ldris.lua
@ -65,13 +65,19 @@ local game = {
|
|||||||
skynetPath = "/skynet.lua" -- location for Skynet API
|
skynetPath = "/skynet.lua" -- location for Skynet API
|
||||||
},
|
},
|
||||||
timers = {},
|
timers = {},
|
||||||
timerNo = 1
|
timerNo = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
for k,v in pairs(game.control) do
|
for k,v in pairs(game.control) do
|
||||||
game.revControl[v] = k
|
game.revControl[v] = k
|
||||||
end
|
end
|
||||||
|
|
||||||
|
game.setPaletteColor = function(...)
|
||||||
|
if game.amountOfPlayers <= 1 then
|
||||||
|
term.setPaletteColor(...)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local getTime = function()
|
local getTime = function()
|
||||||
if os.epoch then
|
if os.epoch then
|
||||||
return os.epoch("utc")
|
return os.epoch("utc")
|
||||||
@ -115,7 +121,7 @@ local tColors = tableCopy(colors)
|
|||||||
tColors.white = 1
|
tColors.white = 1
|
||||||
tColors.brown = nil -- brown is now white
|
tColors.brown = nil -- brown is now white
|
||||||
tColors.special = 4096
|
tColors.special = 4096
|
||||||
term.setPaletteColor(tColors.special, 0xf0f0f0)
|
term.setPaletteColor(tColors.special, 0x353535)
|
||||||
term.setPaletteColor(tColors.white, 0xf0f0f0)
|
term.setPaletteColor(tColors.white, 0xf0f0f0)
|
||||||
|
|
||||||
-- initializes and fixes up a board
|
-- initializes and fixes up a board
|
||||||
@ -763,7 +769,7 @@ local gameOver = function(player, cPlayer)
|
|||||||
renderBoard(player.board, 0, 0, true)
|
renderBoard(player.board, 0, 0, true)
|
||||||
for i = 1, 20 do
|
for i = 1, 20 do
|
||||||
color = color + 0.01
|
color = color + 0.01
|
||||||
term.setPaletteColor(4096, math.sin(color) / 2 + 0.5, math.sin(color) / 2, math.sin(color) / 2)
|
game.setPaletteColor(4096, math.sin(color) / 2 + 0.5, math.sin(color) / 2, math.sin(color) / 2)
|
||||||
end
|
end
|
||||||
sleep(0.1)
|
sleep(0.1)
|
||||||
end
|
end
|
||||||
@ -843,7 +849,7 @@ local ldPalettes = function(light)
|
|||||||
if k == "c" then
|
if k == "c" then
|
||||||
--term.setPaletteColor(to_colors[k], 0xf0f0f0)
|
--term.setPaletteColor(to_colors[k], 0xf0f0f0)
|
||||||
else
|
else
|
||||||
term.setPaletteColor(to_colors[k], table.unpack(v))
|
game.setPaletteColor(to_colors[k], table.unpack(v))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -851,9 +857,9 @@ local ldPalettes = function(light)
|
|||||||
genDarkerPalettes(i)
|
genDarkerPalettes(i)
|
||||||
for k,v in pairs(darkerPalettes) do
|
for k,v in pairs(darkerPalettes) do
|
||||||
if k == "c" then
|
if k == "c" then
|
||||||
--term.setPaletteColor(to_colors[k], 0xf0f0f0)
|
--game.setPaletteColor(to_colors[k], 0xf0f0f0)
|
||||||
else
|
else
|
||||||
term.setPaletteColor(to_colors[k], table.unpack(v))
|
game.setPaletteColor(to_colors[k], table.unpack(v))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
sleep(0.05)
|
sleep(0.05)
|
||||||
@ -887,7 +893,7 @@ local startGame = function(playerNumber)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if canChangeSpecial then
|
if canChangeSpecial then
|
||||||
term.setPaletteColor(4096, mino.ghostColor)
|
game.setPaletteColor(4096, mino.ghostColor)
|
||||||
end
|
end
|
||||||
ghostMino.x = mino.x
|
ghostMino.x = mino.x
|
||||||
ghostMino.y = mino.y
|
ghostMino.y = mino.y
|
||||||
@ -1065,8 +1071,6 @@ local startGame = function(playerNumber)
|
|||||||
)
|
)
|
||||||
m.draw()
|
m.draw()
|
||||||
end
|
end
|
||||||
sendInfo("send_info", false, playerNumber)
|
|
||||||
renderBoard(player.queueBoard, 0, 0, false)
|
|
||||||
|
|
||||||
-- draw held piece
|
-- draw held piece
|
||||||
if cPlayer.hold ~= 0 then
|
if cPlayer.hold ~= 0 then
|
||||||
@ -1097,6 +1101,11 @@ local startGame = function(playerNumber)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
mino.draw()
|
||||||
|
ghostMino.move(0, board.ySize, true)
|
||||||
|
ghostMino.draw()
|
||||||
|
sendInfo("send_info", false, playerNumber)
|
||||||
|
|
||||||
draw()
|
draw()
|
||||||
|
|
||||||
|
|
||||||
@ -1175,7 +1184,8 @@ local startGame = function(playerNumber)
|
|||||||
else
|
else
|
||||||
mino.move(0, cPlayer.fallSteps, true)
|
mino.move(0, cPlayer.fallSteps, true)
|
||||||
if math.floor(mino.oldY) ~= math.floor(mino.y) then
|
if math.floor(mino.oldY) ~= math.floor(mino.y) then
|
||||||
sendInfo("send_info", false)
|
draw(false, true)
|
||||||
|
--sendInfo("send_info", false)
|
||||||
end
|
end
|
||||||
draw()
|
draw()
|
||||||
end
|
end
|
||||||
@ -1239,7 +1249,7 @@ local startGame = function(playerNumber)
|
|||||||
player.flashingSpecial = true
|
player.flashingSpecial = true
|
||||||
renderBoard(board, 0, 0, true)
|
renderBoard(board, 0, 0, true)
|
||||||
for i = 1, 0, -0.12 do
|
for i = 1, 0, -0.12 do
|
||||||
term.setPaletteColor(4096, i,i,i)
|
game.setPaletteColor(4096, i,i,i)
|
||||||
sleep(0.05)
|
sleep(0.05)
|
||||||
end
|
end
|
||||||
for i = #clearedLines, 1, -1 do
|
for i = #clearedLines, 1, -1 do
|
||||||
@ -1260,11 +1270,11 @@ local startGame = function(playerNumber)
|
|||||||
|
|
||||||
if #clearedLines == 0 and game.running and not cPlayer.didHold then
|
if #clearedLines == 0 and game.running and not cPlayer.didHold then
|
||||||
mino.draw(false, "c")
|
mino.draw(false, "c")
|
||||||
term.setPaletteColor(colors.brown, table.unpack(darkerPalettes[mino.color]))
|
game.setPaletteColor(colors.brown, table.unpack(darkerPalettes[mino.color]))
|
||||||
renderBoard(board, 0, 0, true)
|
renderBoard(board, 0, 0, true)
|
||||||
sleep(game.appearanceDelay)
|
sleep(game.appearanceDelay)
|
||||||
mino.draw(true)
|
mino.draw(true)
|
||||||
renderBoard(board, 0, 0, true)
|
renderBoard(board, 0, 0, false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -1388,7 +1398,7 @@ local networking = function()
|
|||||||
game.p = msg.p
|
game.p = msg.p
|
||||||
end
|
end
|
||||||
if msg.specialColor then
|
if msg.specialColor then
|
||||||
term.setPaletteColor(tColors.special, table.unpack(msg.specialColor))
|
game.setPaletteColor(tColors.special, table.unpack(msg.specialColor))
|
||||||
end
|
end
|
||||||
os.queueEvent("new_player_info", msg.p)
|
os.queueEvent("new_player_info", msg.p)
|
||||||
end
|
end
|
||||||
@ -1397,7 +1407,7 @@ local networking = function()
|
|||||||
end
|
end
|
||||||
if msg.command == "flash_special" then
|
if msg.command == "flash_special" then
|
||||||
for i = 1, 0, -0.12 do
|
for i = 1, 0, -0.12 do
|
||||||
term.setPaletteColor(4096, i,i,i)
|
game.setPaletteColor(4096, i,i,i)
|
||||||
renderBoard(game.p[msg.you].board, 0, 0, true)
|
renderBoard(game.p[msg.you].board, 0, 0, true)
|
||||||
sleep(0.05)
|
sleep(0.05)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user