From eb28a628f29e890a85d268d819a805da22b2192c Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Wed, 5 Feb 2025 23:45:26 -0500 Subject: [PATCH] buttonControlledThrow() simplification --- src/main.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main.lua b/src/main.lua index 4150541..6f1430a 100644 --- a/src/main.lua +++ b/src/main.lua @@ -766,16 +766,12 @@ end function buttonControlledThrow(thrower, throwFlyMs, forbidThrowHome) local targetBase if playdate.buttonIsPressed(playdate.kButtonLeft) then - throwBall(Bases[Third].x, Bases[Third].y, playdate.easingFunctions.linear, throwFlyMs) targetBase = Bases[Third] elseif playdate.buttonIsPressed(playdate.kButtonUp) then - throwBall(Bases[Second].x, Bases[Second].y, playdate.easingFunctions.linear, throwFlyMs) targetBase = Bases[Second] -- TODO - or shortstop - whoever's closer elseif playdate.buttonIsPressed(playdate.kButtonRight) then - throwBall(Bases[First].x, Bases[First].y, playdate.easingFunctions.linear, throwFlyMs) targetBase = Bases[First] elseif not forbidThrowHome and playdate.buttonIsPressed(playdate.kButtonDown) then - throwBall(Bases[Home].x, Bases[Home].y, playdate.easingFunctions.linear, throwFlyMs) targetBase = Bases[Home] else return false @@ -784,9 +780,12 @@ function buttonControlledThrow(thrower, throwFlyMs, forbidThrowHome) local closestFielder = utils.getNearestOf(fielders, targetBase.x, targetBase.y, function(fielder) return fielder ~= thrower end) + + throwBall(targetBase.x, targetBase.y, playdate.easingFunctions.linear, throwFlyMs) closestFielder.target = targetBase secondsSinceLastRunnerMove = 0 offenseMode = Offense.running + return true end