59 lines
1.6 KiB
Lua
59 lines
1.6 KiB
Lua
-- selene: allow(shadowing)
|
|
local gfx = playdate.graphics
|
|
|
|
---@alias SpriteCollection { smiling: pd_image, lowHat: pd_image, frowning: pd_image, back: pd_image }
|
|
|
|
---@param image pd_image
|
|
---@param drawInverted boolean
|
|
function maybeDrawInverted(image, x, y, drawInverted)
|
|
-- TODO: Bring logo up a pixel on the dark player base?
|
|
local drawMode = gfx.getImageDrawMode()
|
|
if drawInverted then
|
|
gfx.setImageDrawMode(gfx.kDrawModeInverted)
|
|
end
|
|
image:draw(x, y)
|
|
gfx.setImageDrawMode(drawMode)
|
|
end
|
|
|
|
---@return SpriteCollection
|
|
---@param base pd_image
|
|
---@param isDark boolean
|
|
function buildCollection(base, back, logo, isDark)
|
|
local smiling = gfx.image.new(base:getSize())
|
|
gfx.lockFocus(smiling)
|
|
base:draw(0, 0)
|
|
Hat:draw(6, 0)
|
|
PlayerSmile:draw(5, 9)
|
|
maybeDrawInverted(logo, 3, 25, isDark)
|
|
|
|
local lowHat = gfx.image.new(base:getSize())
|
|
gfx.lockFocus(lowHat)
|
|
base:draw(0, 0)
|
|
Hat:draw(6, 2)
|
|
PlayerSmile:draw(5, 9)
|
|
maybeDrawInverted(logo, 3, 25, isDark)
|
|
|
|
local frowning = gfx.image.new(base:getSize())
|
|
|
|
gfx.lockFocus(frowning)
|
|
base:draw(0, 0)
|
|
maybeDrawInverted(logo, 3, 25, isDark)
|
|
Hat:draw(6, 0)
|
|
PlayerFrown:draw(5, 9)
|
|
|
|
gfx.unlockFocus()
|
|
|
|
return {
|
|
smiling = smiling,
|
|
lowHat = lowHat,
|
|
frowning = frowning,
|
|
back = back,
|
|
}
|
|
end
|
|
|
|
--selene: allow(unscoped_variables)
|
|
AwayTeamSprites = buildCollection(DarkPlayerBase, DarkPlayerBack, BaseLogo, true)
|
|
|
|
--selene: allow(unscoped_variables)
|
|
HomeTeamSprites = buildCollection(LightPlayerBase, LightPlayerBack, FrownLogo, false)
|