Add music + sound effects to assets.lua2p
This commit is contained in:
parent
8dc999fd72
commit
324673ea98
|
@ -2,7 +2,6 @@
|
||||||
"Lua.runtime.version": "Lua 5.4",
|
"Lua.runtime.version": "Lua 5.4",
|
||||||
"Lua.diagnostics.disable": ["undefined-global", "lowercase-global"],
|
"Lua.diagnostics.disable": ["undefined-global", "lowercase-global"],
|
||||||
"Lua.diagnostics.globals": ["playdate", "import"],
|
"Lua.diagnostics.globals": ["playdate", "import"],
|
||||||
"Lua.runtime.nonstandardSymbol": ["+=", "-=", "*=", "/="],
|
|
||||||
"Lua.workspace.library": ["/home/sage/Downloads/PlaydateSDK-2.6.2/CoreLibs"],
|
"Lua.workspace.library": ["/home/sage/Downloads/PlaydateSDK-2.6.2/CoreLibs"],
|
||||||
"Lua.workspace.preloadFileSize": 1000
|
"Lua.workspace.preloadFileSize": 1000
|
||||||
}
|
}
|
|
@ -29,3 +29,17 @@ Minimap = playdate.graphics.image.new("images/game/Minimap.png")
|
||||||
--selene: allow(unscoped_variables)
|
--selene: allow(unscoped_variables)
|
||||||
GrassBackground = playdate.graphics.image.new("images/game/GrassBackground.png")
|
GrassBackground = playdate.graphics.image.new("images/game/GrassBackground.png")
|
||||||
|
|
||||||
|
--selene: allow(unused_variable)
|
||||||
|
--selene: allow(unscoped_variables)
|
||||||
|
BatCrackReverb = playdate.sound.sampleplayer.new("sounds/BatCrackReverb.wav")
|
||||||
|
|
||||||
|
--selene: allow(unused_variable)
|
||||||
|
--selene: allow(unscoped_variables)
|
||||||
|
BootTune = playdate.sound.sampleplayer.new("music/BootTune.wav")
|
||||||
|
--selene: allow(unused_variable)
|
||||||
|
--selene: allow(unscoped_variables)
|
||||||
|
BootTuneOrgany = playdate.sound.sampleplayer.new("music/BootTuneOrgany.wav")
|
||||||
|
--selene: allow(unused_variable)
|
||||||
|
--selene: allow(unscoped_variables)
|
||||||
|
TinnyBackground = playdate.sound.sampleplayer.new("music/TinnyBackground.wav")
|
||||||
|
|
||||||
|
|
|
@ -20,3 +20,5 @@ function generatedFileWarning()
|
||||||
end) !!(generatedFileWarning())
|
end) !!(generatedFileWarning())
|
||||||
|
|
||||||
!!(dirLookup('images/game', 'png', 'playdate.graphics.image.new'))
|
!!(dirLookup('images/game', 'png', 'playdate.graphics.image.new'))
|
||||||
|
!!(dirLookup('sounds', 'wav', 'playdate.sound.sampleplayer.new'))
|
||||||
|
!!(dirLookup('music', 'wav', 'playdate.sound.sampleplayer.new'))
|
||||||
|
|
|
@ -60,6 +60,8 @@ C.PitchStartY, C.PitchEndY = 105, 240
|
||||||
--- The max distance at which a fielder can tag out a runner.
|
--- The max distance at which a fielder can tag out a runner.
|
||||||
C.TagDistance = 15
|
C.TagDistance = 15
|
||||||
|
|
||||||
|
C.BallCatchHitbox = 3
|
||||||
|
|
||||||
--- The max distance at which a runner can be considered on base.
|
--- The max distance at which a runner can be considered on base.
|
||||||
C.BaseHitbox = 10
|
C.BaseHitbox = 10
|
||||||
|
|
||||||
|
|
18
src/main.lua
18
src/main.lua
|
@ -39,17 +39,11 @@ import 'draw/fielder'
|
||||||
-- selene: allow(shadowing)
|
-- selene: allow(shadowing)
|
||||||
local gfx <const>, C <const> = playdate.graphics, C
|
local gfx <const>, C <const> = playdate.graphics, C
|
||||||
|
|
||||||
local BootTune <const> = playdate.sound.sampleplayer.new("sounds/boot-tune.wav")
|
|
||||||
-- local BootTune <const> = playdate.sound.sampleplayer.new("sounds/boot-tune-organy.wav")
|
|
||||||
local TinnyBackground <const> = playdate.sound.sampleplayer.new("sounds/tinny-background.wav")
|
|
||||||
local BatCrackSound <const> = playdate.sound.sampleplayer.new("sounds/bat-crack-reverb.wav")
|
|
||||||
|
|
||||||
local PlayerImageBlipper <const> = blipper.new(100, Player, PlayerLowHat)
|
local PlayerImageBlipper <const> = blipper.new(100, Player, PlayerLowHat)
|
||||||
|
|
||||||
local FielderDanceAnimator <const> = gfx.animator.new(1, 10, 0, utils.easingHill)
|
local FielderDanceAnimator <const> = gfx.animator.new(1, 10, 0, utils.easingHill)
|
||||||
FielderDanceAnimator.repeatCount = C.DanceBounceCount - 1
|
FielderDanceAnimator.repeatCount = C.DanceBounceCount - 1
|
||||||
|
|
||||||
-- selene: allow(unused_variable)
|
|
||||||
function fieldersDance()
|
function fieldersDance()
|
||||||
FielderDanceAnimator:reset(C.DanceBounceMs)
|
FielderDanceAnimator:reset(C.DanceBounceMs)
|
||||||
end
|
end
|
||||||
|
@ -289,15 +283,13 @@ function isTouchingBase(x, y)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
local BallCatchHitbox = 3
|
|
||||||
|
|
||||||
--- Returns true only if the given point is touching the ball at its current position
|
--- Returns true only if the given point is touching the ball at its current position
|
||||||
---@param x number
|
---@param x number
|
||||||
---@param y number
|
---@param y number
|
||||||
---@return boolean, number
|
---@return boolean, number
|
||||||
function isTouchingBall(x, y)
|
function isTouchingBall(x, y)
|
||||||
local ballDistance = utils.distanceBetween(x, y, ball.x, ball.y)
|
local ballDistance = utils.distanceBetween(x, y, ball.x, ball.y)
|
||||||
return ballDistance < BallCatchHitbox, ballDistance
|
return ballDistance < C.BallCatchHitbox, ballDistance
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param base Base
|
---@param base Base
|
||||||
|
@ -347,7 +339,10 @@ function outRunner(runner, message)
|
||||||
updateForcedRunners()
|
updateForcedRunners()
|
||||||
|
|
||||||
announcer:say(message or "YOU'RE OUT!")
|
announcer:say(message or "YOU'RE OUT!")
|
||||||
if outs == 3 then
|
if outs < 3 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local currentlyFieldingTeam = battingTeam == teams.home and teams.away or teams.home
|
local currentlyFieldingTeam = battingTeam == teams.home and teams.away or teams.home
|
||||||
local gameOver = inning == 9 and teams.away.score ~= teams.home.score
|
local gameOver = inning == 9 and teams.away.score ~= teams.home.score
|
||||||
if not gameOver then
|
if not gameOver then
|
||||||
|
@ -372,7 +367,6 @@ function outRunner(runner, message)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param runnerIndex number
|
---@param runnerIndex number
|
||||||
|
@ -642,7 +636,7 @@ function updateBatting(batDeg, batSpeed)
|
||||||
and utils.pointDirectlyUnderLine(ball.x, ball.y, batBase.x, batBase.y, batTip.x, batTip.y, C.Screen.H)
|
and utils.pointDirectlyUnderLine(ball.x, ball.y, batBase.x, batBase.y, batTip.x, batTip.y, C.Screen.H)
|
||||||
and ball.y < 232
|
and ball.y < 232
|
||||||
then
|
then
|
||||||
BatCrackSound:play()
|
BatCrackReverb:play()
|
||||||
offenseMode = C.Offense.running
|
offenseMode = C.Offense.running
|
||||||
local ballAngle = batAngle + math.rad(90)
|
local ballAngle = batAngle + math.rad(90)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue