147 lines
3.0 KiB
Lua
147 lines
3.0 KiB
Lua
C = {}
|
|
|
|
C.Screen = {
|
|
W = playdate and playdate.display.getWidth() or 400,
|
|
H = playdate and playdate.display.getHeight() or 240,
|
|
}
|
|
|
|
C.Center = utils.xy(C.Screen.W / 2, C.Screen.H / 2)
|
|
|
|
C.StrikeZoneStartX = C.Center.x - 16
|
|
C.StrikeZoneEndX = C.StrikeZoneStartX + 24
|
|
C.StrikeZoneStartY = C.Screen.H - 35
|
|
|
|
--- @alias Base {
|
|
--- x: number,
|
|
--- y: number,
|
|
--- }
|
|
|
|
---@type Base[]
|
|
C.Bases = {
|
|
utils.xy(C.Screen.W * 0.93, C.Screen.H * 0.52),
|
|
utils.xy(C.Screen.W * 0.47, C.Screen.H * 0.19),
|
|
utils.xy(C.Screen.W * 0.03, C.Screen.H * 0.52),
|
|
utils.xy(C.Screen.W * 0.474, C.Screen.H * 0.79),
|
|
}
|
|
|
|
C.First, C.Second, C.Third, C.Home = 1, 2, 3, 4
|
|
C.FieldHeight = C.Bases[C.Home].y - C.Bases[C.Second].y
|
|
|
|
-- Pseudo-base for batter to target
|
|
C.RightHandedBattersBox = {
|
|
x = C.Bases[C.Home].x - 30,
|
|
y = C.Bases[C.Home].y + 10,
|
|
}
|
|
|
|
---@type table<Base, Base | nil>
|
|
C.NextBaseMap = {
|
|
[C.RightHandedBattersBox] = nil, -- Runner should not escape the box before a hit!
|
|
[C.Bases[C.First]] = C.Bases[C.Second],
|
|
[C.Bases[C.Second]] = C.Bases[C.Third],
|
|
[C.Bases[C.Third]] = C.Bases[C.Home],
|
|
}
|
|
|
|
C.LeftFoulLine = {
|
|
x1 = C.Center.x,
|
|
y1 = 220,
|
|
x2 = -1800,
|
|
y2 = -465,
|
|
}
|
|
|
|
C.RightFoulLine = {
|
|
x1 = C.Center.x,
|
|
y1 = 218,
|
|
x2 = 2120,
|
|
y2 = -465,
|
|
}
|
|
|
|
--- Angle to align the bat to
|
|
C.CrankOffsetDeg = 90
|
|
|
|
C.DanceBounceMs = 500
|
|
C.DanceBounceCount = 4
|
|
|
|
C.ScoreboardDelayMs = 2000
|
|
|
|
--- Used to draw the ball well out of bounds, and
|
|
--- generally as a check for whether or not it's in play.
|
|
C.BallOffscreen = 999
|
|
|
|
C.PitchAfterSeconds = 6
|
|
C.ReturnToPitcherAfterSeconds = 2.4
|
|
C.PitchFlyMs = 1050
|
|
C.PitchStart = utils.xy(195, 105)
|
|
C.PitchEndY = 240
|
|
|
|
C.DefaultLaunchPower = 4
|
|
|
|
--- The max distance at which a fielder can tag out a runner.
|
|
C.TagDistance = 15
|
|
|
|
C.BallCatchHitbox = 3
|
|
|
|
--- The max distance at which a runner can be considered on base.
|
|
C.BaseHitbox = 10
|
|
|
|
C.BattingPower = 25
|
|
C.BatterHandPos = utils.xy(25, 15)
|
|
C.GloveZ = 0 -- 10
|
|
|
|
C.SmallestBallRadius = 6
|
|
|
|
C.BatLength = 35
|
|
|
|
---@alias OffenseState "batting" | "running" | "walking" | "homeRun"
|
|
--- An enum for what state the offense is in
|
|
---@type table<string, OffenseState>
|
|
C.Offense = {
|
|
batting = "batting",
|
|
running = "running",
|
|
walking = "walking",
|
|
homeRun = "homeRun",
|
|
}
|
|
|
|
---@alias Side "offense" | "defense"
|
|
|
|
C.PitcherStartPos = {
|
|
x = C.Screen.W * 0.48,
|
|
y = C.Screen.H * 0.40,
|
|
}
|
|
|
|
--- Controls how hard the ball can be hit, and
|
|
--- how fast the ball can be thrown.
|
|
C.CrankPower = 10
|
|
|
|
C.FielderRunMult = 1.3
|
|
|
|
C.PlayerHeightOffset = 20
|
|
|
|
C.UserThrowPower = 0.3
|
|
|
|
--- How fast baserunners move after a walk
|
|
C.WalkedRunnerSpeed = 10
|
|
|
|
C.ResetFieldersAfterSeconds = 2.5
|
|
|
|
C.OutfieldWall = {
|
|
{ x = -400, y = -103 },
|
|
{ x = -167, y = -208 },
|
|
{ x = 50, y = -211 },
|
|
{ x = 150, y = -181 },
|
|
{ x = 339, y = -176 },
|
|
{ x = 450, y = -221 },
|
|
{ x = 700, y = -209 },
|
|
{ x = 785, y = -59 },
|
|
{ x = 801, y = -16 },
|
|
}
|
|
|
|
C.BottomOfOutfieldWall = {}
|
|
|
|
for i, v in ipairs(C.OutfieldWall) do
|
|
C.BottomOfOutfieldWall[i] = utils.xy(v.x, v.y + 40)
|
|
end
|
|
|
|
if not playdate then
|
|
return C
|
|
end
|