notsanequarium/scenes/gameplay/draw/food.lua
2021-01-24 02:30:01 +03:00

13 lines
No EOL
500 B
Lua

return function(food, sheets, spritescale)
local sw, sh = love.graphics.getDimensions()
for _,f in ipairs(food) do
local sheet = sheets['food' .. (f.type)]
local x = f.x * sw
local y = f.y * sh
local frame = math.floor((f.time%1) * #sheet.quads) + 1
love.graphics.setColor(1, 1, 1, 1 - f.deathtimer)
love.graphics.draw(sheet.spriteSheet, sheet.quads[math.max(math.min(frame, #sheet.quads), 1)], x, y, 0, spritescale, spritescale, sheet.width/2, sheet.height/2)
end
end