Updated bg and player sprites.
Player is taller now. Fixed out handling.
|
@ -37,6 +37,7 @@ end
|
||||||
|
|
||||||
---@param runner integer | Runner
|
---@param runner integer | Runner
|
||||||
---@param message string | nil
|
---@param message string | nil
|
||||||
|
---@return boolean wasFinalOut
|
||||||
function Baserunning:outRunner(runner, message)
|
function Baserunning:outRunner(runner, message)
|
||||||
self.outs = self.outs + 1
|
self.outs = self.outs + 1
|
||||||
if type(runner) ~= "number" then
|
if type(runner) ~= "number" then
|
||||||
|
@ -56,13 +57,16 @@ function Baserunning:outRunner(runner, message)
|
||||||
|
|
||||||
self.announcer:say(message or "YOU'RE OUT!")
|
self.announcer:say(message or "YOU'RE OUT!")
|
||||||
if self.outs < 3 then
|
if self.outs < 3 then
|
||||||
return
|
return false
|
||||||
end
|
end
|
||||||
|
self.outs = 0
|
||||||
|
|
||||||
-- TODO: outRunners/scoredRunners split
|
-- TODO: outRunners/scoredRunners split
|
||||||
while #self.runners > 0 do
|
while #self.runners > 0 do
|
||||||
self.outRunners[#self.outRunners + 1] = table.remove(self.runners, #self.runners)
|
self.outRunners[#self.outRunners + 1] = table.remove(self.runners, #self.runners)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function Baserunning:outEligibleRunners(fielder)
|
function Baserunning:outEligibleRunners(fielder)
|
||||||
|
@ -78,7 +82,10 @@ function Baserunning:outEligibleRunners(fielder)
|
||||||
-- Tag out
|
-- Tag out
|
||||||
or not runnerOnBase and utils.distanceBetween(runner.x, runner.y, fielder.x, fielder.y) < C.TagDistance
|
or not runnerOnBase and utils.distanceBetween(runner.x, runner.y, fielder.x, fielder.y) < C.TagDistance
|
||||||
then
|
then
|
||||||
self:outRunner(i)
|
local wasFinalOut = self:outRunner(i)
|
||||||
|
if wasFinalOut then
|
||||||
|
return true -- Don't keep running up self.outs after it's been reset
|
||||||
|
end
|
||||||
didOutRunner = true
|
didOutRunner = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 720 B After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 681 B After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 712 B After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 711 B After Width: | Height: | Size: 4.4 KiB |
22
src/main.lua
|
@ -66,7 +66,6 @@ local teams <const> = {
|
||||||
|
|
||||||
local PlayerTeam <const> = teams.away
|
local PlayerTeam <const> = teams.away
|
||||||
local battingTeam = teams.away
|
local battingTeam = teams.away
|
||||||
local outs = 0
|
|
||||||
local inning = 1
|
local inning = 1
|
||||||
local offenseState = C.Offense.batting
|
local offenseState = C.Offense.batting
|
||||||
|
|
||||||
|
@ -78,7 +77,7 @@ local secondsSincePitchAllowed = -5
|
||||||
|
|
||||||
local catcherThrownBall = false
|
local catcherThrownBall = false
|
||||||
|
|
||||||
local BatterHandPos <const> = utils.xy(10, 25)
|
local BatterHandPos <const> = utils.xy(10, 15)
|
||||||
|
|
||||||
local batBase <const> = utils.xy(C.Center.x - 34, 215)
|
local batBase <const> = utils.xy(C.Center.x - 34, 215)
|
||||||
local batTip <const> = utils.xy(0, 0)
|
local batTip <const> = utils.xy(0, 0)
|
||||||
|
@ -174,8 +173,8 @@ end
|
||||||
---@param runner integer | Runner
|
---@param runner integer | Runner
|
||||||
---@param message string | nil
|
---@param message string | nil
|
||||||
local function outRunner(runner, message)
|
local function outRunner(runner, message)
|
||||||
baserunning:outRunner(runner, message)
|
local wasFinalOut = baserunning:outRunner(runner, message)
|
||||||
if baserunning.outs < 3 then
|
if not wasFinalOut then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -187,9 +186,10 @@ local function outRunner(runner, message)
|
||||||
fielding:benchTo(currentlyFieldingTeam.benchPosition)
|
fielding:benchTo(currentlyFieldingTeam.benchPosition)
|
||||||
announcer:say("SWITCHING SIDES...")
|
announcer:say("SWITCHING SIDES...")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- TODO: Make the overlay handle its own dang delay.
|
||||||
-- Delay to keep end-of-inning on the scoreboard for a few seconds
|
-- Delay to keep end-of-inning on the scoreboard for a few seconds
|
||||||
playdate.timer.new(3000, function()
|
playdate.timer.new(3000, function()
|
||||||
outs = 0
|
|
||||||
battingTeam = currentlyFieldingTeam
|
battingTeam = currentlyFieldingTeam
|
||||||
if gameOver then
|
if gameOver then
|
||||||
announcer:say("AND THAT'S THE BALL GAME!")
|
announcer:say("AND THAT'S THE BALL GAME!")
|
||||||
|
@ -295,7 +295,6 @@ local function updateBatting(batDeg, batSpeed)
|
||||||
end
|
end
|
||||||
local ballDestX = ball.x + (ballVelX * C.BattingPower)
|
local ballDestX = ball.x + (ballVelX * C.BattingPower)
|
||||||
local ballDestY = ball.y + (ballVelY * C.BattingPower)
|
local ballDestY = ball.y + (ballVelY * C.BattingPower)
|
||||||
ballDestY = ballDestY - 300
|
|
||||||
-- Hit!
|
-- Hit!
|
||||||
local hitBallScaler = gfx.animator.new(2000, 9 + (mult * mult * 0.5), C.SmallestBallRadius, utils.easingHill)
|
local hitBallScaler = gfx.animator.new(2000, 9 + (mult * mult * 0.5), C.SmallestBallRadius, utils.easingHill)
|
||||||
launchBall(ballDestX, ballDestY, playdate.easingFunctions.outQuint, 2000, nil, hitBallScaler)
|
launchBall(ballDestX, ballDestY, playdate.easingFunctions.outQuint, 2000, nil, hitBallScaler)
|
||||||
|
@ -477,22 +476,23 @@ function playdate.update()
|
||||||
playdate.ui.crankIndicator:draw()
|
playdate.ui.crankIndicator:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local playerHeightOffset = 10
|
||||||
-- TODO? Scale sprites down as y increases
|
-- TODO? Scale sprites down as y increases
|
||||||
for _, runner in pairs(baserunning.runners) do
|
for _, runner in pairs(baserunning.runners) do
|
||||||
if runner == baserunning.batter then
|
if runner == baserunning.batter then
|
||||||
if batAngleDeg > 50 and batAngleDeg < 200 then
|
if batAngleDeg > 50 and batAngleDeg < 200 then
|
||||||
PlayerBack:draw(runner.x, runner.y)
|
PlayerBack:draw(runner.x, runner.y - playerHeightOffset)
|
||||||
else
|
else
|
||||||
Player:draw(runner.x, runner.y)
|
Player:draw(runner.x, runner.y - playerHeightOffset)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- TODO? Change blip speed depending on runner speed?
|
-- TODO? Change blip speed depending on runner speed?
|
||||||
PlayerImageBlipper:draw(false, runner.x, runner.y)
|
PlayerImageBlipper:draw(false, runner.x, runner.y - playerHeightOffset)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, runner in pairs(baserunning.outRunners) do
|
for _, runner in pairs(baserunning.outRunners) do
|
||||||
PlayerFrown:draw(runner.x, runner.y)
|
PlayerFrown:draw(runner.x, runner.y - playerHeightOffset)
|
||||||
end
|
end
|
||||||
|
|
||||||
if not ballIsHeld then
|
if not ballIsHeld then
|
||||||
|
@ -509,7 +509,7 @@ function playdate.update()
|
||||||
if math.abs(offsetX) > 10 or math.abs(offsetY) > 10 then
|
if math.abs(offsetX) > 10 or math.abs(offsetY) > 10 then
|
||||||
drawMinimap(baserunning.runners, fielding.fielders)
|
drawMinimap(baserunning.runners, fielding.fielders)
|
||||||
end
|
end
|
||||||
drawScoreboard(0, C.Screen.H * 0.77, teams, outs, battingTeam, inning)
|
drawScoreboard(0, C.Screen.H * 0.77, teams, baserunning.outs, battingTeam, inning)
|
||||||
drawBallsAndStrikes(290, C.Screen.H - 20, pitchTracker.balls, pitchTracker.strikes)
|
drawBallsAndStrikes(290, C.Screen.H - 20, pitchTracker.balls, pitchTracker.strikes)
|
||||||
announcer:draw(C.Center.x, 10)
|
announcer:draw(C.Center.x, 10)
|
||||||
end
|
end
|
||||||
|
|