Posted 30 June 2016 - 04:57 PM
So I am trying to make a Rubik's Cube in CC and done some tests with the rendering of the pieces, something weird i found out was that if a launch the code first time it works great
And the second time I do it, it renders the cubes in black color (if i reboot the computer it works again)
Maybe there is something wrong with the code so that's why i've posted it here
And the second time I do it, it renders the cubes in black color (if i reboot the computer it works again)
Maybe there is something wrong with the code so that's why i've posted it here
w,h = term.getSize()
colors = {colors.white,colors.green,colors.yellow,colors.red,colors.blue,colors.orange}
local function renderCube(side)
for k,v in pairs(cube[side]) do
drawPiece(cube[side][k],k)
end
end
function drawPiece(var,nPiece)
if nPiece == 1 then
paintutils.drawFilledBox(w/2-2-5,h/2-2-2,w/2-2-2,h/2-2,var)
elseif nPiece == 2 then
paintutils.drawFilledBox(w/2-2,h/2-2-2,w/2-2+3,h/2-2,var)
elseif nPiece == 3 then
paintutils.drawFilledBox(w/2-2+5,h/2-2-2,w/2-2+8,h/2-2,var)
elseif nPiece == 4 then
paintutils.drawFilledBox(w/2-2-5,h/2-2+2,w/2-2-2,h/2-2+4,var)
end
end
for a = 1,100 do
drawPiece(colors[math.random(1,6)],1)
drawPiece(colors[math.random(1,6)],2)
drawPiece(colors[math.random(1,6)],3)
drawPiece(colors[math.random(1,6)],4)
sleep(0.04)
end
Edited on 30 June 2016 - 03:21 PM