Posted 06 March 2014 - 05:48 AM
I started making conways game of life in CC but I have a problem. When I click the pixel at cords (11,1) it also puts a pixel at (1,11) and same for every pixel down that column. It also does it every 11 pixels on the x axis but instead of (22,1) going to (1,22) it goes to (2,11) and (33,1) goes to (3,11) etc. Please help! Thank you! :D/>
cells = {}
function alive(x,y)
if cells[tostring(x)..tostring(y)] == "alive" or cells[tostring(x)..tostring(y)] == "will_die" then
return true
elseif cells[tostring(x)..tostring(y)] == "dead" or cells[tostring(x)..tostring(y)] == "will_live" then
return false
end
end
function drawScreen()
for y = 1,19 do
for x = 1,51 do
term.setCursorPos(x,y)
if alive(x,y) then
term.setBackgroundColor(colors.white)
else
term.setBackgroundColor(colors.black)
end
write(" ")
end
end
end
local running = false
while true do
os.startTimer(1)
local e,p1,p2,p3 = os.pullEvent()
if e == "mouse_click" and not running then
if p1 == 2 then
cells[tostring(p2)..tostring(p3)] = "dead"
else
cells[tostring(p2)..tostring(p3)] = "alive"
end
drawScreen()
elseif e == "key" and keys.getName(p1) == "space" then
if running then
running = false
else
running = true
end
elseif e == "timer" and running then
term.setCursorPos(1,1)
print("test")
end
end