I'm having a lot of headaches with this seemingly simple code.
I'm having difficulty in this line of the code: draw section
when I try to draw, something like
Code: Select all
function love.draw()
love.graphics.rectangle("fill", player.posX, player.posY, 15, 15)
love.graphics.rectangle("fill", player.posX + 20, player.posY + 20, 15, 15) #same draw above, but with a different position
love.graphics.rectangle("fill", player.posX + 50, player.posY + 50, 15, 15) #same
end
Code: Select all
pos = { x = {150, 180, 190},
y = {250, 280, 350}
}
function love.draw()
local i = 1
while i <= 3 do
love.graphics.rectangle("fill", pos.x[i], pos.y[i], 15, 15)
i = i + 1
end
end
I don't understand the logic beyond Draw() function, because, on the one hand, you can write several times to draw an object, but for the while loop it goes out, it makes no sense. Or would it be something more technical like using Metatables or some OOP attempt?
Thanks for your attention!
Best regards!