u/Doithedum

▲ 3 r/love2d

why cant i set a variable to an image without directly setting it?

i want to make it so i can set a "sprite" variable to userdata

but it ends up being nil for some reason

function love.load()
   room = love.graphics.newImage("room.png") --the art
end

function tilerectangle(tx,ty,width,height,id)
    for i=1,height do
        for i=1,width do
            table.insert(tiles,{
                x = tx,
                y = ty,
                type = "room",
                roomid = id,
                sprite = room --when i draw this tile i draw it with the info in here
            })
            tx = tx + 1 * gridsize
        end
        ty = ty + 1 * gridsize
        tx = tx - width * gridsize
    end
end
reddit.com
u/Doithedum — 4 days ago
▲ 4 r/love2d

how exactly would one round to the 0.5s?

--tick
        tick = tick + dt
        if dt == 1 then
            dt = 0
        end
        nestedtick = math.floor(tick)
        if tick > 1 then
            tick = 0
        end

im doing a tick system for animations and such like the above and i use nestedtick to change things per second, but i want to make it so nestedtick rounds to 0, 0.5, 1 so i can make things change a little faster if i want to.

reddit.com
u/Doithedum — 28 days ago