Draw fans in the stands
This commit is contained in:
parent
56c0c27d75
commit
384a14fe5f
|
@ -0,0 +1,36 @@
|
||||||
|
local gfx <const>, C <const> = playdate.graphics, C
|
||||||
|
|
||||||
|
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
|
Binary file not shown.
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 42 KiB |
|
@ -39,6 +39,7 @@ import 'npc.lua'
|
||||||
import 'pitching.lua'
|
import 'pitching.lua'
|
||||||
|
|
||||||
import 'draw/box-score.lua'
|
import 'draw/box-score.lua'
|
||||||
|
import 'draw/fans.lua'
|
||||||
import 'draw/fielder.lua'
|
import 'draw/fielder.lua'
|
||||||
import 'draw/overlay.lua'
|
import 'draw/overlay.lua'
|
||||||
import 'draw/panner.lua'
|
import 'draw/panner.lua'
|
||||||
|
@ -592,6 +593,7 @@ function Game:update()
|
||||||
local offsetX, offsetY = self.panner:get(self.state.deltaSeconds)
|
local offsetX, offsetY = self.panner:get(self.state.deltaSeconds)
|
||||||
gfx.setDrawOffset(offsetX, offsetY)
|
gfx.setDrawOffset(offsetX, offsetY)
|
||||||
|
|
||||||
|
fans.draw()
|
||||||
GrassBackground:draw(-400, -720)
|
GrassBackground:draw(-400, -720)
|
||||||
|
|
||||||
---@type { y: number, drawAction: fun() }[]
|
---@type { y: number, drawAction: fun() }[]
|
||||||
|
|
Loading…
Reference in New Issue