Runners smile instead of frown after scoring.

This commit is contained in:
Sage Vaillancourt 2025-02-17 20:55:35 -05:00
parent c3a9122580
commit 1bdcc62347
3 changed files with 21 additions and 8 deletions

View File

@ -69,7 +69,6 @@ function Ball:launch(destX, destY, easingFunc, flyTimeMs, floaty, customBallScal
if customBallScaler then
self.sizeAnimator = customBallScaler
else
-- TODO? Scale based on distance?
self.sizeAnimator = self.animatorLib.new(flyTimeMs, 9, C.SmallestBallRadius, utils.easingHill)
end
self.yAnimator = self.animatorLib.new(flyTimeMs, self.y, destY, easingFunc)

View File

@ -65,7 +65,6 @@ function Baserunning:outRunner(runner, message)
self.onThirdOut()
self.outs = 0
-- TODO: outRunners/scoredRunners split
while #self.runners > 0 do
self.outRunners[#self.outRunners + 1] = table.remove(self.runners, #self.runners)
end
@ -124,16 +123,27 @@ function Baserunning:convertBatterToRunner()
self.batter = nil -- Demote batter to a mere runner
end
---@param deltaSeconds number
function Baserunning:walkAwayOutRunners(deltaSeconds)
for i, runner in ipairs(self.outRunners) do
local function walkWayOutRunner(deltaSeconds, runner)
if runner.x < C.Screen.W + 50 and runner.y < C.Screen.H + 50 then
runner.x = runner.x + (deltaSeconds * 25)
runner.y = runner.y + (deltaSeconds * 25)
else
return true
end
return false
end
---@param deltaSeconds number
function Baserunning:walkAwayOutRunners(deltaSeconds)
for i, runner in ipairs(self.outRunners) do
if not walkWayOutRunner(deltaSeconds, runner) then
table.remove(self.outRunners, i)
end
end
for i, runner in ipairs(self.scoredRunners) do
if not walkWayOutRunner(deltaSeconds, runner) then
table.remove(self.scoredRunners, i)
end
end
end
---@return Runner
@ -155,7 +165,7 @@ end
---@param runnerIndex number
function Baserunning:runnerScored(runnerIndex)
-- TODO: outRunners/scoredRunners split
self.outRunners[#self.outRunners + 1] = self.runners[runnerIndex]
self.scoredRunners[#self.scoredRunners + 1] = self.runners[runnerIndex]
table.remove(self.runners, runnerIndex)
end

View File

@ -314,6 +314,8 @@ end
---@param scoredRunCount number
function Game:score(scoredRunCount)
-- TODO: end the game when it's the bottom of the ninth the home team is now in the lead.
-- outRunners/scoredRunners split
self:battingTeamCurrentInning().score = self:battingTeamCurrentInning().score + scoredRunCount
self.announcer:say("SCORE!")
@ -613,7 +615,6 @@ function Game:update()
end
local playerHeightOffset = 20
-- TODO? Scale sprites down as y increases
for _, runner in pairs(self.baserunning.runners) do
addDraw(runner.y, function()
if runner == self.baserunning.batter then
@ -644,6 +645,9 @@ function Game:update()
for _, runner in pairs(self.baserunning.outRunners) do
self.state.battingTeamSprites.frowning:draw(runner.x, runner.y - playerHeightOffset)
end
for _, runner in pairs(self.baserunning.scoredRunners) do
self.state.battingTeamSprites.smiling:draw(runner.x, runner.y - playerHeightOffset)
end
if not ballIsHeld then
gfx.setLineWidth(2)