Drawing lines using a table (why doesn't it work?)
Posted: Sun Feb 19, 2017 6:00 pm
Hi, I'd like to draw some lines using a table of coordinates. Oddly, when I create a table manually ('trapezoid' below), the lines draw fine. When I create the table in a loop from random numbers, it does not draw as lines, but will draw as points. In the code below, 'trapezoid' works fine for both, but 'coords' only works for points. Puzzling...
Code: Select all
trapezoid = {200,50, 400,50, 500,300, 100,300, 200,50}
coords = {}
for i = 1, 10 do
x = math.random(5, 500)
y = math.random(5, 500)
coords[i] = {x, y}
end
function love.draw(dt)
love.graphics.line(coords)
love.graphics.points(coords)
love.graphics.line(trapezoid)
love.graphics.points(trapezoid)
end