Code: Select all
function unit:draw()
love.graphics.draw(unit.img, unit.x, unit.y)
end
Code: Select all
for i, unit in ipairs(units) do
unit:draw()
end
Oh and, yes, unit code is being loaded, obviously. And unit is a table with x, y, hp, stuff like that in it.
EDIT: Might as well put the whole unit code, since I get an error on unit:draw func anyway, about x/y being tables not numbers... here it is... help me fix dis too
Code: Select all
units = {}
unit = {
x = {},
y = {},
speed = 100,
color = "255, 255, 255",
hp = 40,
img = love.graphics.newImage("resource/unit_green.png"),
laserdmg = 10
}
function unit.create(xpos, ypos)
table.insert(unit.x, xpos)
table.insert(unit.y, ypos)
units[#units+1] = {x=xpos, y=ypos}
end
function unit:draw()
love.graphics.draw(unit.img, unit.x, unit.y)
end
function unit:update(dt)
end