summaryrefslogtreecommitdiff
path: root/main.lua
diff options
context:
space:
mode:
authorcursed22bc <admin@pixeldawn.org>2026-03-11 12:50:56 +0200
committercursed22bc <admin@pixeldawn.org>2026-03-11 12:50:56 +0200
commit8c5a91acb224312ea511c7ff502c44bb9fe7452b (patch)
tree194a2aee7f92fabbab79cc0ab64f0d2989b7d55e /main.lua
parentcd432860828a84aca93852a09cf05fc0e6294bab (diff)
sfx and other polish
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/main.lua b/main.lua
index 19c350d..6f2ee53 100644
--- a/main.lua
+++ b/main.lua
@@ -23,6 +23,7 @@ local cameraModule = require("camera")
local camera = nil
local fonts = require("fonts")
local HUD = require("hud")
+local sfx = require("sfx")
local hud = nil
local previousState = nil
@@ -88,6 +89,8 @@ function states.game.load()
gameFinishPhase = nil
gameFinishTimer = 0
irisRadius = 0
+ sfx.stop("UI_loop_song")
+ sfx.loop("game_ambient_loop")
end
function states.game.update(dt)
@@ -167,12 +170,17 @@ function states.menu.load()
menuTime = 0
love.mouse.setVisible(true)
menuHover = nil
+ sfx.stop("game_ambient_loop")
+ sfx.stop("running")
+ sfx.setLiquidEffect(false)
+ sfx.loop("UI_loop_song")
end
function states.menu.update(dt)
menuTime = menuTime + dt
local mx, my = love.mouse.getPosition()
local cx, cy = screenToCanvas(mx, my)
+ local prevHover = menuHover
menuHover = nil
for _, btn in ipairs(menuItems) do
if cx >= btn.x and cx <= btn.x + btn.w and cy >= btn.y and cy <= btn.y + btn.h then
@@ -180,6 +188,9 @@ function states.menu.update(dt)
break
end
end
+ if menuHover and menuHover ~= prevHover then
+ sfx.play("UI")
+ end
end
function states.menu.draw()
@@ -267,6 +278,8 @@ function love.load()
canvas = love.graphics.newCanvas(CANVAS_WIDTH, CANVAS_HEIGHT)
canvas:setFilter("nearest", "nearest")
+ sfx.load()
+
local ok, shader = pcall(love.graphics.newShader, "shaders/smooth_camera.glsl")
smoothCameraShader = ok and shader or nil
if not smoothCameraShader then
@@ -290,6 +303,10 @@ function love.load()
local state = states[currentState]
if state and state.load then state.load() end
+
+ if currentState == "menu" then
+ sfx.loop("UI_loop_song")
+ end
end
function love.resize(w, h)
@@ -325,10 +342,12 @@ function love.keypressed(key, scancode, isrepeat)
previousState = currentState
currentState = "hud"
love.mouse.setVisible(true)
+ sfx.play("HUD")
elseif currentState == "hud" then
currentState = previousState or "game"
previousState = nil
love.mouse.setVisible(false)
+ sfx.play("HUD")
end
end
if (key == "space" or key == "up" or key == "w") and not isrepeat then