143 lines
3.0 KiB
Lua
143 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.PitchStartX = 195
|
|
C.PitchStartY, C.PitchEndY = 105, 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
|
|
|
|
-- TODO: enums implemented this way are probably going to be difficult to serialize!
|
|
|
|
---@alias OffenseState "batting" | "running" | "walking"
|
|
--- An enum for what state the offense is in
|
|
---@type table<string, OffenseState>
|
|
C.Offense = {
|
|
batting = "batting",
|
|
running = "running",
|
|
walking = "walking",
|
|
}
|
|
|
|
---@alias Side "offense" | "defense"
|
|
|
|
C.PitcherStartPos = {
|
|
x = C.Screen.W * 0.48,
|
|
y = C.Screen.H * 0.40,
|
|
}
|
|
|
|
C.ThrowMeterMax = 10
|
|
C.ThrowMeterDrainPerSec = 150
|
|
|
|
--- Controls how hard the ball can be hit, and
|
|
--- how fast the ball can be thrown.
|
|
C.CrankPower = 10
|
|
|
|
C.FielderRunMult = 1.3
|
|
|
|
C.UserThrowPower = 0.3
|
|
|
|
--- How fast baserunners move after a walk
|
|
C.WalkedRunnerSpeed = 10
|
|
|
|
C.ResetFieldersAfterSeconds = 2.5
|
|
|
|
C.OutfieldWall = {
|
|
{ x = 0, y = 137 },
|
|
{ x = 233, y = 32 },
|
|
{ x = 450, y = 29 },
|
|
{ x = 550, y = 59 },
|
|
{ x = 739, y = 64 },
|
|
{ x = 850, y = 19 },
|
|
{ x = 1100, y = 31 },
|
|
{ x = 1185, y = 181 },
|
|
{ x = 1201, y = 224 },
|
|
}
|
|
|
|
if not playdate then
|
|
return C
|
|
end
|