diff --git a/game/love_src/asset/audio/sfx/race/va/Test2.mp3 b/game/love_src/asset/audio/sfx/race/va/Test2.mp3 new file mode 100644 index 0000000..b9df60e Binary files /dev/null and b/game/love_src/asset/audio/sfx/race/va/Test2.mp3 differ diff --git a/game/love_src/asset/audio/sfx/race/va/Test3.mp3 b/game/love_src/asset/audio/sfx/race/va/Test3.mp3 new file mode 100644 index 0000000..0ea551c Binary files /dev/null and b/game/love_src/asset/audio/sfx/race/va/Test3.mp3 differ diff --git a/game/love_src/asset/audio/sfx/race/va/test1.mp3 b/game/love_src/asset/audio/sfx/race/va/test1.mp3 new file mode 100644 index 0000000..e2343a0 Binary files /dev/null and b/game/love_src/asset/audio/sfx/race/va/test1.mp3 differ diff --git a/game/love_src/src/new/world/main_menu/components/button.lua b/game/love_src/src/new/world/main_menu/components/button.lua index 86b10ec..52ad725 100644 --- a/game/love_src/src/new/world/main_menu/components/button.lua +++ b/game/love_src/src/new/world/main_menu/components/button.lua @@ -32,6 +32,8 @@ function world:load(entity, data) self.data = data or default self.data.temp_color = self.data.bg_color self.mouse = "not click" + self.sfx_highlight = love.audio.newSource("love_src/asset/audio/sfx/book_flip.4.ogg", "static") + self.sfx_click = love.audio.newSource("love_src/asset/audio/sfx/book_flip.8.ogg", "static") end -- x1 y1 -- (x1 + w1) y1 @@ -59,6 +61,16 @@ local function transform(x, y, w, h, ox, oy,lox, loy, s) return x, y, w, h, ox, oy, lox, loy end +function world:highlight() + self.data.temp_color = self.data.highlight_color + self.sfx_highlight:play() +end + +function world:click() + self.data.func() + self.sfx_click:play() +end + function world:update(dt) local xm, ym = love.mouse.getPosition() local x, y, w, h, ox, oy, lox, loy, s = self.data.pos[1], self.data.pos[2], @@ -68,7 +80,7 @@ function world:update(dt) self.data.scale x, y, w, h, ox, oy, lox, loy = transform(x, y, w, h, ox, oy, lox, loy, s) if (is_inside(x, y, w, h, xm, ym)) then - self.data.temp_color = self.data.highlight_color + self:highlight() if (love.mouse.isDown(1)) then if (self.mouse == "not click") then self.mouse = "click" @@ -76,7 +88,7 @@ function world:update(dt) else if (self.mouse == "click") then self.mouse = "not click" - self.data.func() + self:click() end end else diff --git a/game/love_src/src/new/world/race/init.lua b/game/love_src/src/new/world/race/init.lua index eb051e6..0260207 100644 --- a/game/love_src/src/new/world/race/init.lua +++ b/game/love_src/src/new/world/race/init.lua @@ -107,12 +107,35 @@ function world:load(data, entities_data) self:setup() end +local phases = { + intro = { + is_played = false, + source = love.audio.newSource("love_src/asset/audio/sfx/race/va/test1.mp3", "static"), + }, + mid = { + is_played = false, + source = love.audio.newSource("love_src/asset/audio/sfx/race/va/Test2.mp3", "static"), + }, + ed = { + is_played = false, + source = love.audio.newSource("love_src/asset/audio/sfx/race/va/Test3.mp3", "static") + } +} + +local phase = "intro" + function world:update(dt) for _, e in ipairs(self.entities) do for t, c in pairs(e.components) do c:update(dt) end end + if (phases[phase]) then + if (not phases[phase].source:isPlaying() and not phases[phase].is_played) then + phases[phase].source:play() + phases[phase].is_played = true + end + end end function world:draw() diff --git a/game/main.lua b/game/main.lua index 369622b..86c1386 100644 --- a/game/main.lua +++ b/game/main.lua @@ -227,10 +227,12 @@ local world_data = { current = wm["main_menu"] +local bgm = love.audio.newSource("love_src/asset/audio/bgm/Ensemble.mp3", "stream") +bgm:setLooping(true) +bgm:play() + function load_world(world_to_load) - print(current) current = world_to_load - print(current) local c_w = world_data[current] world[current] = c_w.world world[current]:load(c_w.data, c_w.entities_data)