local gfx <const> = playdate.graphics

fans = {}

local FanImages <const> = { DarkSkinFan, LightSkinFan }
local FanWidth <const>, FanHeight <const> = FanImages[1]:getSize()
local BgWidth <const>, BgHeight <const> = GrassBackground:getSize()

local AudienceImage1 <const> = gfx.image.new(BgWidth, BgHeight)
local AudienceImage2 <const> = gfx.image.new(BgWidth, BgHeight)

local height = 0
while height < BgHeight do
    local width = 0
    while width < BgWidth do
        gfx.pushContext(AudienceImage1)
        local image = FanImages[math.random(#FanImages)]
        local jiggle = math.random(5)
        image:draw(width + jiggle, height)
        gfx.popContext()

        gfx.pushContext(AudienceImage2)
        image:draw(width + jiggle + math.random(0, 2), height)
        gfx.popContext()

        width = width + FanWidth
    end
    height = height + FanHeight - 10
end
local AudienceMovement = gfx.animation.blinker.new(200, 200, true)
AudienceMovement:start()

function fans.draw()
    local currentImage = AudienceMovement.on and AudienceImage1 or AudienceImage2
    currentImage:draw(-400, -720)
end
