Add some quick MenuMusic
And extract a bit more pitchTracker logic
This commit is contained in:
parent
2d812f2046
commit
aebbc35bac
|
@ -41,6 +41,8 @@ BootTune = playdate.sound.sampleplayer.new("music/BootTune.wav")
|
|||
BootTuneOrgany = playdate.sound.sampleplayer.new("music/BootTuneOrgany.wav")
|
||||
-- luacheck: ignore
|
||||
TinnyBackground = playdate.sound.sampleplayer.new("music/TinnyBackground.wav")
|
||||
-- luacheck: ignore
|
||||
MenuMusic = playdate.sound.sampleplayer.new("music/MenuMusic.wav")
|
||||
|
||||
Logos = {
|
||||
{ name = "Base", image = playdate.graphics.image.new("images/game/logos/Base.png") },
|
||||
|
|
|
@ -11,6 +11,7 @@ local StartFont <const> = gfx.font.new("fonts/Roobert-20-Medium.pft")
|
|||
--- Will replace playdate.update when the menu is done.
|
||||
---@param next { new: fun(settings: Settings): { update: fun(self) } }
|
||||
function MainMenu.start(next)
|
||||
MenuMusic:play(0)
|
||||
MainMenu.next = next
|
||||
playdate.update = MainMenu.update
|
||||
end
|
||||
|
@ -25,6 +26,7 @@ local function startGame()
|
|||
})
|
||||
playdate.resetElapsedTime()
|
||||
transitionBetween(MainMenu, next)
|
||||
MenuMusic:setPaused(true)
|
||||
end
|
||||
|
||||
local function pausingEaser(baseEaser)
|
||||
|
|
|
@ -490,11 +490,7 @@ function Game:updateGameState()
|
|||
end
|
||||
|
||||
if self.state.offenseState == C.Offense.batting then
|
||||
if self.state.ball.y < C.StrikeZoneStartY then
|
||||
pitchTracker.recordedPitchX = nil
|
||||
elseif not pitchTracker.recordedPitchX then
|
||||
pitchTracker.recordedPitchX = self.state.ball.x
|
||||
end
|
||||
pitchTracker:recordIfPassed(self.state.ball)
|
||||
|
||||
local pitcher = self.fielding.fielders.pitcher
|
||||
if utils.distanceBetween(pitcher.x, pitcher.y, C.PitcherStartPos.x, C.PitcherStartPos.y) < C.BaseHitbox then
|
||||
|
|
Binary file not shown.
|
@ -250,10 +250,8 @@ function utils.totalScores(stats)
|
|||
end
|
||||
|
||||
PitchOutcomes = {
|
||||
Strike = {},
|
||||
StrikeOut = {},
|
||||
Ball = {},
|
||||
Walk = {},
|
||||
StrikeOut = "StrikeOut",
|
||||
Walk = "Walk",
|
||||
}
|
||||
|
||||
pitchTracker = {
|
||||
|
@ -263,39 +261,47 @@ pitchTracker = {
|
|||
|
||||
strikes = 0,
|
||||
balls = 0,
|
||||
|
||||
reset = function(self)
|
||||
self.strikes = 0
|
||||
self.balls = 0
|
||||
end,
|
||||
|
||||
---@param didSwing boolean
|
||||
---@param fieldingTeamInningData TeamInningData
|
||||
updatePitchCounts = function(self, didSwing, fieldingTeamInningData)
|
||||
if not self.recordedPitchX then
|
||||
return
|
||||
end
|
||||
|
||||
local currentPitchingStats = fieldingTeamInningData.pitching
|
||||
|
||||
if didSwing or self.recordedPitchX > C.StrikeZoneStartX and self.recordedPitchX < C.StrikeZoneEndX then
|
||||
self.strikes = self.strikes + 1
|
||||
currentPitchingStats.strikes = currentPitchingStats.strikes + 1
|
||||
if self.strikes >= 3 then
|
||||
self:reset()
|
||||
return PitchOutcomes.StrikeOut
|
||||
end
|
||||
else
|
||||
self.balls = self.balls + 1
|
||||
currentPitchingStats.balls = currentPitchingStats.balls + 1
|
||||
if self.balls >= 4 then
|
||||
self:reset()
|
||||
return PitchOutcomes.Walk
|
||||
end
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
function pitchTracker:reset()
|
||||
self.strikes = 0
|
||||
self.balls = 0
|
||||
end
|
||||
|
||||
function pitchTracker:recordIfPassed(ball)
|
||||
if ball.y < C.StrikeZoneStartY then
|
||||
self.recordedPitchX = nil
|
||||
elseif not pitchTracker.recordedPitchX then
|
||||
self.recordedPitchX = ball.x
|
||||
end
|
||||
end
|
||||
|
||||
---@param didSwing boolean
|
||||
---@param fieldingTeamInningData TeamInningData
|
||||
function pitchTracker:updatePitchCounts(didSwing, fieldingTeamInningData)
|
||||
if not self.recordedPitchX then
|
||||
return
|
||||
end
|
||||
|
||||
local currentPitchingStats = fieldingTeamInningData.pitching
|
||||
|
||||
if didSwing or self.recordedPitchX > C.StrikeZoneStartX and self.recordedPitchX < C.StrikeZoneEndX then
|
||||
self.strikes = self.strikes + 1
|
||||
currentPitchingStats.strikes = currentPitchingStats.strikes + 1
|
||||
if self.strikes >= 3 then
|
||||
self:reset()
|
||||
return PitchOutcomes.StrikeOut
|
||||
end
|
||||
else
|
||||
self.balls = self.balls + 1
|
||||
currentPitchingStats.balls = currentPitchingStats.balls + 1
|
||||
if self.balls >= 4 then
|
||||
self:reset()
|
||||
return PitchOutcomes.Walk
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-----------------
|
||||
-- Throw Meter --
|
||||
-----------------
|
||||
|
|
Loading…
Reference in New Issue