Fix pitching

This commit is contained in:
Sage Vaillancourt 2025-02-24 19:49:32 -05:00
parent 9bbd68c302
commit 09e48b65b4
4 changed files with 7 additions and 4 deletions

View File

@ -518,7 +518,7 @@ function Game:updatePitching(defenseHandler)
end
if pitchTracker.secondsSinceLastPitch > C.PitchAfterSeconds then
defenseHandler:pitch()
self:pitch(defenseHandler:pitch())
end
end

View File

@ -18,6 +18,8 @@ function Npc.new(runners, fielders)
}, { __index = Npc })
end
function Npc.update() end
-- TODO: FAR more nuanced NPC batting.
---@param ball XyPair
---@param pitchIsOver boolean

View File

@ -54,12 +54,13 @@ Pitches = {
y = gfx.animator.new(C.PitchFlyMs, C.PitchStart.y, C.PitchEndY, playdate.easingFunctions.linear),
}
end,
-- Wobbbleball
-- Wobbleball
function(accuracy, ball)
local missBy = getPitchMissBy(accuracy)
return {
x = {
currentValue = function()
return getPitchMissBy(accuracy)
return missBy
+ C.PitchStart.x
+ (10 * math.sin((ball.yAnimator:currentValue() - C.PitchStart.y) / 10))
end,

View File

@ -48,7 +48,7 @@ function UserInput:pitch()
if powerRatio then
local throwFly = C.PitchFlyMs / powerRatio
if throwFly and not self.buttonControlledThrow(throwFly, true) then
userPitch(throwFly, accuracy)
return userPitch(throwFly, accuracy)
end
end
end