Runners smile instead of frown after scoring.
This commit is contained in:
parent
c3a9122580
commit
1bdcc62347
|
@ -69,7 +69,6 @@ function Ball:launch(destX, destY, easingFunc, flyTimeMs, floaty, customBallScal
|
||||||
if customBallScaler then
|
if customBallScaler then
|
||||||
self.sizeAnimator = customBallScaler
|
self.sizeAnimator = customBallScaler
|
||||||
else
|
else
|
||||||
-- TODO? Scale based on distance?
|
|
||||||
self.sizeAnimator = self.animatorLib.new(flyTimeMs, 9, C.SmallestBallRadius, utils.easingHill)
|
self.sizeAnimator = self.animatorLib.new(flyTimeMs, 9, C.SmallestBallRadius, utils.easingHill)
|
||||||
end
|
end
|
||||||
self.yAnimator = self.animatorLib.new(flyTimeMs, self.y, destY, easingFunc)
|
self.yAnimator = self.animatorLib.new(flyTimeMs, self.y, destY, easingFunc)
|
||||||
|
|
|
@ -65,7 +65,6 @@ function Baserunning:outRunner(runner, message)
|
||||||
self.onThirdOut()
|
self.onThirdOut()
|
||||||
self.outs = 0
|
self.outs = 0
|
||||||
|
|
||||||
-- TODO: outRunners/scoredRunners split
|
|
||||||
while #self.runners > 0 do
|
while #self.runners > 0 do
|
||||||
self.outRunners[#self.outRunners + 1] = table.remove(self.runners, #self.runners)
|
self.outRunners[#self.outRunners + 1] = table.remove(self.runners, #self.runners)
|
||||||
end
|
end
|
||||||
|
@ -124,16 +123,27 @@ function Baserunning:convertBatterToRunner()
|
||||||
self.batter = nil -- Demote batter to a mere runner
|
self.batter = nil -- Demote batter to a mere runner
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
---@param deltaSeconds number
|
---@param deltaSeconds number
|
||||||
function Baserunning:walkAwayOutRunners(deltaSeconds)
|
function Baserunning:walkAwayOutRunners(deltaSeconds)
|
||||||
for i, runner in ipairs(self.outRunners) do
|
for i, runner in ipairs(self.outRunners) do
|
||||||
if runner.x < C.Screen.W + 50 and runner.y < C.Screen.H + 50 then
|
if not walkWayOutRunner(deltaSeconds, runner) then
|
||||||
runner.x = runner.x + (deltaSeconds * 25)
|
|
||||||
runner.y = runner.y + (deltaSeconds * 25)
|
|
||||||
else
|
|
||||||
table.remove(self.outRunners, i)
|
table.remove(self.outRunners, i)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
for i, runner in ipairs(self.scoredRunners) do
|
||||||
|
if not walkWayOutRunner(deltaSeconds, runner) then
|
||||||
|
table.remove(self.scoredRunners, i)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@return Runner
|
---@return Runner
|
||||||
|
@ -155,7 +165,7 @@ end
|
||||||
---@param runnerIndex number
|
---@param runnerIndex number
|
||||||
function Baserunning:runnerScored(runnerIndex)
|
function Baserunning:runnerScored(runnerIndex)
|
||||||
-- TODO: outRunners/scoredRunners split
|
-- 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)
|
table.remove(self.runners, runnerIndex)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -314,6 +314,8 @@ end
|
||||||
|
|
||||||
---@param scoredRunCount number
|
---@param scoredRunCount number
|
||||||
function Game:score(scoredRunCount)
|
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:battingTeamCurrentInning().score = self:battingTeamCurrentInning().score + scoredRunCount
|
||||||
|
|
||||||
self.announcer:say("SCORE!")
|
self.announcer:say("SCORE!")
|
||||||
|
@ -613,7 +615,6 @@ function Game:update()
|
||||||
end
|
end
|
||||||
|
|
||||||
local playerHeightOffset = 20
|
local playerHeightOffset = 20
|
||||||
-- TODO? Scale sprites down as y increases
|
|
||||||
for _, runner in pairs(self.baserunning.runners) do
|
for _, runner in pairs(self.baserunning.runners) do
|
||||||
addDraw(runner.y, function()
|
addDraw(runner.y, function()
|
||||||
if runner == self.baserunning.batter then
|
if runner == self.baserunning.batter then
|
||||||
|
@ -644,6 +645,9 @@ function Game:update()
|
||||||
for _, runner in pairs(self.baserunning.outRunners) do
|
for _, runner in pairs(self.baserunning.outRunners) do
|
||||||
self.state.battingTeamSprites.frowning:draw(runner.x, runner.y - playerHeightOffset)
|
self.state.battingTeamSprites.frowning:draw(runner.x, runner.y - playerHeightOffset)
|
||||||
end
|
end
|
||||||
|
for _, runner in pairs(self.baserunning.scoredRunners) do
|
||||||
|
self.state.battingTeamSprites.smiling:draw(runner.x, runner.y - playerHeightOffset)
|
||||||
|
end
|
||||||
|
|
||||||
if not ballIsHeld then
|
if not ballIsHeld then
|
||||||
gfx.setLineWidth(2)
|
gfx.setLineWidth(2)
|
||||||
|
|
Loading…
Reference in New Issue