Start drawing fielders in minimap
This commit is contained in:
parent
fedf680626
commit
50ddd67730
|
@ -11,7 +11,7 @@ local MinimapOffsetX <const> = MinimapPosX + 5
|
||||||
local MinimapMultY <const> = 0.70 * MinimapSizeY / C.FieldHeight
|
local MinimapMultY <const> = 0.70 * MinimapSizeY / C.FieldHeight
|
||||||
local MinimapOffsetY <const> = MinimapPosY - 15
|
local MinimapOffsetY <const> = MinimapPosY - 15
|
||||||
|
|
||||||
function drawMinimap(runners)
|
function drawMinimap(runners, fielders)
|
||||||
Minimap:draw(MinimapPosX, MinimapPosY)
|
Minimap:draw(MinimapPosX, MinimapPosY)
|
||||||
gfx.setColor(gfx.kColorBlack)
|
gfx.setColor(gfx.kColorBlack)
|
||||||
for _, runner in pairs(runners) do
|
for _, runner in pairs(runners) do
|
||||||
|
@ -19,6 +19,12 @@ function drawMinimap(runners)
|
||||||
local y = (MinimapMultY * runner.y) + MinimapOffsetY
|
local y = (MinimapMultY * runner.y) + MinimapOffsetY
|
||||||
gfx.fillRect(x, y, 8, 8)
|
gfx.fillRect(x, y, 8, 8)
|
||||||
end
|
end
|
||||||
|
-- TODO: Don't draw when out of bounds
|
||||||
|
for _, fielder in pairs(fielders) do
|
||||||
|
local x = (MinimapMultX * fielder.x) + MinimapOffsetX
|
||||||
|
local y = (MinimapMultY * fielder.y) + MinimapOffsetY
|
||||||
|
gfx.drawCircleAtPoint(x, y, 4)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local BallStrikeMarginY <const> = 4
|
local BallStrikeMarginY <const> = 4
|
||||||
|
|
|
@ -88,15 +88,15 @@ end
|
||||||
---@param ball XYPair
|
---@param ball XYPair
|
||||||
---@return Fielder | nil fielderTouchingBall nil if no fielder is currently touching the ball
|
---@return Fielder | nil fielderTouchingBall nil if no fielder is currently touching the ball
|
||||||
function Field.updateFielderPositions(self, ball, deltaSeconds)
|
function Field.updateFielderPositions(self, ball, deltaSeconds)
|
||||||
local fielderTouchingBallLocal = nil
|
local fielderTouchingBall = nil
|
||||||
for _, fielder in pairs(self.fielders) do
|
for _, fielder in pairs(self.fielders) do
|
||||||
local isTouchingBall = updateFielderPosition(deltaSeconds, fielder, ball)
|
local isTouchingBall = updateFielderPosition(deltaSeconds, fielder, ball)
|
||||||
if isTouchingBall then
|
if isTouchingBall then
|
||||||
fielderTouchingBallLocal = fielder
|
fielderTouchingBall = fielder
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.fielderTouchingBall = fielderTouchingBallLocal
|
self.fielderTouchingBall = fielderTouchingBall
|
||||||
return fielderTouchingBallLocal
|
return fielderTouchingBall
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO? Start moving target fielders close sooner?
|
-- TODO? Start moving target fielders close sooner?
|
||||||
|
|
|
@ -687,7 +687,7 @@ function playdate.update()
|
||||||
|
|
||||||
gfx.setDrawOffset(0, 0)
|
gfx.setDrawOffset(0, 0)
|
||||||
if math.abs(offsetX) > 10 or math.abs(offsetY) > 10 then
|
if math.abs(offsetX) > 10 or math.abs(offsetY) > 10 then
|
||||||
drawMinimap(runners)
|
drawMinimap(runners, Field.fielders)
|
||||||
end
|
end
|
||||||
drawScoreboard(0, C.Screen.H * 0.77, teams, outs, battingTeam, inning)
|
drawScoreboard(0, C.Screen.H * 0.77, teams, outs, battingTeam, inning)
|
||||||
drawBallsAndStrikes(290, C.Screen.H - 20, pitchTracker.balls, pitchTracker.strikes)
|
drawBallsAndStrikes(290, C.Screen.H - 20, pitchTracker.balls, pitchTracker.strikes)
|
||||||
|
|
Loading…
Reference in New Issue