From 8c5a91acb224312ea511c7ff502c44bb9fe7452b Mon Sep 17 00:00:00 2001 From: cursed22bc Date: Wed, 11 Mar 2026 12:50:56 +0200 Subject: sfx and other polish --- main.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'main.lua') 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 -- cgit v1.2.3