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")
|
BootTuneOrgany = playdate.sound.sampleplayer.new("music/BootTuneOrgany.wav")
|
||||||
-- luacheck: ignore
|
-- luacheck: ignore
|
||||||
TinnyBackground = playdate.sound.sampleplayer.new("music/TinnyBackground.wav")
|
TinnyBackground = playdate.sound.sampleplayer.new("music/TinnyBackground.wav")
|
||||||
|
-- luacheck: ignore
|
||||||
|
MenuMusic = playdate.sound.sampleplayer.new("music/MenuMusic.wav")
|
||||||
|
|
||||||
Logos = {
|
Logos = {
|
||||||
{ name = "Base", image = playdate.graphics.image.new("images/game/logos/Base.png") },
|
{ 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.
|
--- Will replace playdate.update when the menu is done.
|
||||||
---@param next { new: fun(settings: Settings): { update: fun(self) } }
|
---@param next { new: fun(settings: Settings): { update: fun(self) } }
|
||||||
function MainMenu.start(next)
|
function MainMenu.start(next)
|
||||||
|
MenuMusic:play(0)
|
||||||
MainMenu.next = next
|
MainMenu.next = next
|
||||||
playdate.update = MainMenu.update
|
playdate.update = MainMenu.update
|
||||||
end
|
end
|
||||||
|
@ -25,6 +26,7 @@ local function startGame()
|
||||||
})
|
})
|
||||||
playdate.resetElapsedTime()
|
playdate.resetElapsedTime()
|
||||||
transitionBetween(MainMenu, next)
|
transitionBetween(MainMenu, next)
|
||||||
|
MenuMusic:setPaused(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function pausingEaser(baseEaser)
|
local function pausingEaser(baseEaser)
|
||||||
|
|
|
@ -490,11 +490,7 @@ function Game:updateGameState()
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.state.offenseState == C.Offense.batting then
|
if self.state.offenseState == C.Offense.batting then
|
||||||
if self.state.ball.y < C.StrikeZoneStartY then
|
pitchTracker:recordIfPassed(self.state.ball)
|
||||||
pitchTracker.recordedPitchX = nil
|
|
||||||
elseif not pitchTracker.recordedPitchX then
|
|
||||||
pitchTracker.recordedPitchX = self.state.ball.x
|
|
||||||
end
|
|
||||||
|
|
||||||
local pitcher = self.fielding.fielders.pitcher
|
local pitcher = self.fielding.fielders.pitcher
|
||||||
if utils.distanceBetween(pitcher.x, pitcher.y, C.PitcherStartPos.x, C.PitcherStartPos.y) < C.BaseHitbox then
|
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
|
end
|
||||||
|
|
||||||
PitchOutcomes = {
|
PitchOutcomes = {
|
||||||
Strike = {},
|
StrikeOut = "StrikeOut",
|
||||||
StrikeOut = {},
|
Walk = "Walk",
|
||||||
Ball = {},
|
|
||||||
Walk = {},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pitchTracker = {
|
pitchTracker = {
|
||||||
|
@ -263,39 +261,47 @@ pitchTracker = {
|
||||||
|
|
||||||
strikes = 0,
|
strikes = 0,
|
||||||
balls = 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 --
|
-- Throw Meter --
|
||||||
-----------------
|
-----------------
|
||||||
|
|
Loading…
Reference in New Issue