notsanequarium/scenes/gameplay/draw/food.lua

23 lines
847 B
Lua
Raw Normal View History

2021-01-25 18:05:06 +00:00
local sheetNames = {
'food1', 'food2', 'food3', 'potion'
}
return function(food, sheets, spritescale, starpotionequipped)
2021-01-23 23:30:01 +00:00
local sw, sh = love.graphics.getDimensions()
for _,f in ipairs(food) do
2021-01-25 18:05:06 +00:00
local sheet = sheets[sheetNames[f.type]]
2021-01-23 23:30:01 +00:00
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
2021-01-25 18:05:06 +00:00
if starpotionequipped then
local sheet = sheets.potion
love.graphics.setColor(1, 1, 1, 0.8)
love.graphics.draw(sheet.spriteSheet, sheet.quads[1], love.mouse.getX(), love.mouse.getY(), 0, spritescale, spritescale, sheet.width/2, sheet.height/2)
end
2021-01-23 23:30:01 +00:00
end