From 4cf1755d05a63452feca03d2e380b149fcaa76c2 Mon Sep 17 00:00:00 2001 From: Aki Date: Thu, 6 Apr 2017 18:40:27 +0200 Subject: Moved music.lua, cleaned-up its code; Fixed requires for main, World and Menu --- not/Music.lua | 25 +++++++++++++++++++++++++ not/World.lua | 1 + 2 files changed, 26 insertions(+) create mode 100644 not/Music.lua (limited to 'not') diff --git a/not/Music.lua b/not/Music.lua new file mode 100644 index 0000000..ee930f4 --- /dev/null +++ b/not/Music.lua @@ -0,0 +1,25 @@ +--- `Music` +-- Simple music player object that plays and loops selected track in single Scene. +Music = { + source = --[[love.audio.newSource]]nil +} + +Music.__index = Music + +function Music:new (trackName) + local o = setmetatable({}, self) + o:init(trackName) + return o +end + +-- TODO: trackName should be passed without file extension. +function Music:init (trackName) + self.source = love.audio.newSource("assets/music/" .. trackName) + self.source:setLooping(true) + self.source:setVolume(.7) + self.source:play() +end + +function Music:delete () + self.source:stop() +end \ No newline at end of file diff --git a/not/World.lua b/not/World.lua index 579fff2..2a6106c 100644 --- a/not/World.lua +++ b/not/World.lua @@ -31,6 +31,7 @@ require "not.Cloud" require "not.Effect" require "not.Decoration" require "not.Ray" +require "not.Music" -- Constructor of `World` ZA WARUDO! function World:new (map, nauts) -- cgit v1.1