summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-04-06 18:40:27 +0200
committerAki <nthirtyone@gmail.com>2017-04-06 18:40:27 +0200
commit4cf1755d05a63452feca03d2e380b149fcaa76c2 (patch)
treedeaa00880a83e230f70ae423eb616a817c8828fc
parent9a5b629d8c1719af62667235c59950862b46b771 (diff)
downloadroflnauts-4cf1755d05a63452feca03d2e380b149fcaa76c2.zip
roflnauts-4cf1755d05a63452feca03d2e380b149fcaa76c2.tar.gz
roflnauts-4cf1755d05a63452feca03d2e380b149fcaa76c2.tar.bz2
Moved music.lua, cleaned-up its code; Fixed requires for main, World and Menu
-rw-r--r--main.lua1
-rw-r--r--menu.lua2
-rw-r--r--music.lua27
-rw-r--r--not/Music.lua25
-rw-r--r--not/World.lua1
5 files changed, 27 insertions, 29 deletions
diff --git a/main.lua b/main.lua
index b985648..bdee6a3 100644
--- a/main.lua
+++ b/main.lua
@@ -28,7 +28,6 @@ require "not.World"
require "camera"
require "menu"
require "controller"
-require "music"
require "settings"
-- Temporary debug
diff --git a/menu.lua b/menu.lua
index fef46df..47e1b25 100644
--- a/menu.lua
+++ b/menu.lua
@@ -2,7 +2,7 @@
-- It creates single screen of a menu
-- I do know that model I used here and in `World` loading configuration files is not flawless but I did not want to rewrite `World`s one but wanted to keep things similar at least in project scope.
-require "music"
+require "not.Music"
-- Here it begins
Menu = {
diff --git a/music.lua b/music.lua
deleted file mode 100644
index 1ac26bb..0000000
--- a/music.lua
+++ /dev/null
@@ -1,27 +0,0 @@
--- `Music`
--- Simple music player object that plays and loops selected track in single Scene.
-
--- WHOLE CODE HAS FLAG OF "need a cleanup"
-
--- Metatable of `Music`
--- nils initialized in constructor
-Music = {
- track = nil,
- source = nil
-}
-function Music:new(track)
- -- Meta
- local o = {}
- setmetatable(o, self)
- self.__index = self
- -- Init
- o.track = track
- o.source = love.audio.newSource("assets/music/" .. o.track)
- o.source:setLooping(true)
- o.source:setVolume(.7)
- o.source:play()
- return o
-end
-function Music:delete()
- self.source:stop()
-end \ No newline at end of file
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)