buttonControlledThrow() simplification
This commit is contained in:
parent
8319b554ec
commit
eb28a628f2
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue