From 09e48b65b4c3c6b539f95bbfd2f6816c16ca1199 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Mon, 24 Feb 2025 19:49:32 -0500 Subject: [PATCH] Fix pitching --- src/main.lua | 2 +- src/npc.lua | 2 ++ src/pitching.lua | 5 +++-- src/user-input.lua | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main.lua b/src/main.lua index b1219b5..709f7f9 100644 --- a/src/main.lua +++ b/src/main.lua @@ -518,7 +518,7 @@ function Game:updatePitching(defenseHandler) end if pitchTracker.secondsSinceLastPitch > C.PitchAfterSeconds then - defenseHandler:pitch() + self:pitch(defenseHandler:pitch()) end end diff --git a/src/npc.lua b/src/npc.lua index 57f6cb3..be0eb24 100644 --- a/src/npc.lua +++ b/src/npc.lua @@ -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 diff --git a/src/pitching.lua b/src/pitching.lua index 42381a3..18d9aa3 100644 --- a/src/pitching.lua +++ b/src/pitching.lua @@ -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, diff --git a/src/user-input.lua b/src/user-input.lua index 8655411..02a78b9 100644 --- a/src/user-input.lua +++ b/src/user-input.lua @@ -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