From ae8ce1a11ca02297ff9fe05b3146c620a2485975 Mon Sep 17 00:00:00 2001 From: Aki Date: Tue, 27 Jun 2017 09:05:16 +0200 Subject: Scenes now use MusicPlayer --- not/Menu.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'not/Menu.lua') diff --git a/not/Menu.lua b/not/Menu.lua index 8ef1861..cd6d963 100644 --- a/not/Menu.lua +++ b/not/Menu.lua @@ -38,7 +38,7 @@ Menu = { Menu.__index = Menu -require "not.Music" +require "not.MusicPlayer" function Menu:new (name) local o = setmetatable({}, self) @@ -54,7 +54,7 @@ function Menu:new (name) end function Menu:init (name) - self.music = Music:new("menu.ogg") + self.music = MusicPlayer("menu.ogg") self:open(name) end @@ -141,4 +141,4 @@ function Menu:controlreleased (set, action, key) for _,element in pairs(self.elements) do element:controlreleased(set, action, key) end -end \ No newline at end of file +end -- cgit v1.1 From 47d4e1c229adfffb70b3c984d00049bcebcfc183 Mon Sep 17 00:00:00 2001 From: Aki Date: Wed, 12 Jul 2017 09:04:23 +0200 Subject: All music playing moved to single instance of MusicPlayer --- not/Menu.lua | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'not/Menu.lua') diff --git a/not/Menu.lua b/not/Menu.lua index cd6d963..4dcff5e 100644 --- a/not/Menu.lua +++ b/not/Menu.lua @@ -38,8 +38,6 @@ Menu = { Menu.__index = Menu -require "not.MusicPlayer" - function Menu:new (name) local o = setmetatable({}, self) -- Load statically. @@ -54,13 +52,12 @@ function Menu:new (name) end function Menu:init (name) - self.music = MusicPlayer("menu.ogg") + musicPlayer:setTrack("menu.ogg") + musicPlayer:play() self:open(name) end -function Menu:delete () - self.music:delete() -end +function Menu:delete () end function Menu:open (name) local name = name or "main" -- cgit v1.1 From d161510d2dc33046459e874e716c02c76d49f7d5 Mon Sep 17 00:00:00 2001 From: Aki Date: Wed, 12 Jul 2017 09:38:36 +0200 Subject: Menu moved to new OOP model --- not/Menu.lua | 86 ++++++++++++++++++++++++++++-------------------------------- 1 file changed, 40 insertions(+), 46 deletions(-) (limited to 'not/Menu.lua') diff --git a/not/Menu.lua b/not/Menu.lua index 4dcff5e..1688166 100644 --- a/not/Menu.lua +++ b/not/Menu.lua @@ -1,57 +1,49 @@ --- `Menu` -- 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. -Menu = { - scale = getScale(), - elements = --[[{not.Element}]]nil, - active = 1, - music = --[[not.Music]]nil, - sprite = --[[love.graphics.newImage]]nil, - background = --[[love.graphics.newImage]]nil, - asteroids = --[[love.graphics.newImage]]nil, - stars = --[[love.graphics.newImage]]nil, - asteroids_bounce = 0, - stars_frame = 1, - stars_delay = 0.8, - allowMove = true, - quads = { -- TODO: Could be moved to config file or perhaps QuadManager to manage all quads for animations etc. - button = { - normal = love.graphics.newQuad(0, 0, 58,15, 80,130), - active = love.graphics.newQuad(0, 0, 58,15, 80,130) - }, - portrait = { - normal = love.graphics.newQuad( 0, 15, 32,32, 80,130), - active = love.graphics.newQuad(32, 15, 32,32, 80,130) - }, - panorama = { - normal = love.graphics.newQuad(0,47, 80,42, 80,130), - active = love.graphics.newQuad(0,88, 80,42, 80,130) - }, - arrow_l = love.graphics.newQuad(68, 0, 6, 6, 80,130), - arrow_r = love.graphics.newQuad(74, 0, 6, 6, 80,130), - stars = { - love.graphics.newQuad( 0, 0, 320, 200, 640,200), - love.graphics.newQuad(320, 0, 320, 200, 640,200) - }, - } -} +Menu = require "not.Object":extends() -Menu.__index = Menu +Menu.scale = getScale() +Menu.elements = --[[{not.Element}]]nil +Menu.active = 1 +Menu.music = --[[not.Music]]nil +Menu.sprite = --[[love.graphics.newImage]]nil +Menu.background = --[[love.graphics.newImage]]nil +Menu.asteroids = --[[love.graphics.newImage]]nil +Menu.stars = --[[love.graphics.newImage]]nil +Menu.asteroids_bounce = 0 +Menu.stars_frame = 1 +Menu.stars_delay = 0.8 +Menu.allowMove = true +Menu.quads = { -- TODO: Could be moved to config file or perhaps QuadManager to manage all quads for animations etc. + button = { + normal = love.graphics.newQuad(0, 0, 58,15, 80,130), + active = love.graphics.newQuad(0, 0, 58,15, 80,130) + }, + portrait = { + normal = love.graphics.newQuad( 0, 15, 32,32, 80,130), + active = love.graphics.newQuad(32, 15, 32,32, 80,130) + }, + panorama = { + normal = love.graphics.newQuad(0,47, 80,42, 80,130), + active = love.graphics.newQuad(0,88, 80,42, 80,130) + }, + arrow_l = love.graphics.newQuad(68, 0, 6, 6, 80,130), + arrow_r = love.graphics.newQuad(74, 0, 6, 6, 80,130), + stars = { + love.graphics.newQuad( 0, 0, 320, 200, 640,200), + love.graphics.newQuad(320, 0, 320, 200, 640,200) + }, +} function Menu:new (name) - local o = setmetatable({}, self) -- Load statically. - if self.sprite == nil then - self.sprite = love.graphics.newImage("assets/menu.png") - self.background = love.graphics.newImage("assets/backgrounds/menu.png") - self.asteroids = love.graphics.newImage("assets/asteroids.png") - self.stars = love.graphics.newImage("assets/stars.png") + if Menu.sprite == nil then + Menu.sprite = love.graphics.newImage("assets/menu.png") + Menu.background = love.graphics.newImage("assets/backgrounds/menu.png") + Menu.asteroids = love.graphics.newImage("assets/asteroids.png") + Menu.stars = love.graphics.newImage("assets/stars.png") end - o:init(name) - return o -end - -function Menu:init (name) musicPlayer:setTrack("menu.ogg") musicPlayer:play() self:open(name) @@ -139,3 +131,5 @@ function Menu:controlreleased (set, action, key) element:controlreleased(set, action, key) end end + +return Menu -- cgit v1.1 From 9af261cd204b999e6b2b5a44d5c5eb768f84c49d Mon Sep 17 00:00:00 2001 From: Aki Date: Wed, 12 Jul 2017 16:00:51 +0200 Subject: Created Scene class extended SceneManager a little bit to support multiple scenes --- not/Menu.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'not/Menu.lua') diff --git a/not/Menu.lua b/not/Menu.lua index 1688166..ea47993 100644 --- a/not/Menu.lua +++ b/not/Menu.lua @@ -1,7 +1,7 @@ --- `Menu` -- 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. -Menu = require "not.Object":extends() +Menu = require "not.Scene":extends() Menu.scale = getScale() Menu.elements = --[[{not.Element}]]nil -- cgit v1.1 From 96fef88f56fdcdf95bc5783eb2b3b881ff435ba0 Mon Sep 17 00:00:00 2001 From: Aki Date: Fri, 14 Jul 2017 21:54:46 +0200 Subject: Background in menu moved to separate class Weird noise added to menu configs to use single MenuBackground instance Initial pause menu added --- not/Menu.lua | 35 ++++++----------------------------- 1 file changed, 6 insertions(+), 29 deletions(-) (limited to 'not/Menu.lua') diff --git a/not/Menu.lua b/not/Menu.lua index ea47993..a837045 100644 --- a/not/Menu.lua +++ b/not/Menu.lua @@ -8,12 +8,6 @@ Menu.elements = --[[{not.Element}]]nil Menu.active = 1 Menu.music = --[[not.Music]]nil Menu.sprite = --[[love.graphics.newImage]]nil -Menu.background = --[[love.graphics.newImage]]nil -Menu.asteroids = --[[love.graphics.newImage]]nil -Menu.stars = --[[love.graphics.newImage]]nil -Menu.asteroids_bounce = 0 -Menu.stars_frame = 1 -Menu.stars_delay = 0.8 Menu.allowMove = true Menu.quads = { -- TODO: Could be moved to config file or perhaps QuadManager to manage all quads for animations etc. button = { @@ -30,22 +24,16 @@ Menu.quads = { -- TODO: Could be moved to config file or perhaps QuadManager to }, arrow_l = love.graphics.newQuad(68, 0, 6, 6, 80,130), arrow_r = love.graphics.newQuad(74, 0, 6, 6, 80,130), - stars = { - love.graphics.newQuad( 0, 0, 320, 200, 640,200), - love.graphics.newQuad(320, 0, 320, 200, 640,200) - }, } function Menu:new (name) -- Load statically. if Menu.sprite == nil then Menu.sprite = love.graphics.newImage("assets/menu.png") - Menu.background = love.graphics.newImage("assets/backgrounds/menu.png") - Menu.asteroids = love.graphics.newImage("assets/asteroids.png") - Menu.stars = love.graphics.newImage("assets/stars.png") end musicPlayer:setTrack("menu.ogg") musicPlayer:play() + self.elements = {} self:open(name) end @@ -54,8 +42,11 @@ function Menu:delete () end function Menu:open (name) local name = name or "main" self.active = Menu.active --Menu.active is initial - self.elements = love.filesystem.load(string.format("config/menus/%s.lua", name))(self) - self.elements[self.active]:focus() + self.elements = love.filesystem.load(string.format("config/menus/%s.lua", name))(self, self.elements[1]) + -- Common with `next` method. + if not self.elements[self.active]:focus() then + self:next() + end end -- Return reference to quads table and menu sprite @@ -88,24 +79,10 @@ function Menu:update (dt) for _,element in pairs(self.elements) do element:update(dt) end - self.asteroids_bounce = self.asteroids_bounce + dt*0.1 - if self.asteroids_bounce > 2 then self.asteroids_bounce = self.asteroids_bounce - 2 end - self.stars_delay = self.stars_delay - dt - if self.stars_delay < 0 then - self.stars_delay = self.stars_delay + Menu.stars_delay --Menu.stars_delay is initial - if self.stars_frame == 2 then - self.stars_frame = 1 - else - self.stars_frame = 2 - end - end end function Menu:draw () local scale = self.scale local scaler = getRealScale() - love.graphics.draw(self.background, 0, 0, 0, scaler, scaler) - love.graphics.draw(self.stars, self.quads.stars[self.stars_frame], 0, 0, 0, scaler, scaler) - love.graphics.draw(self.asteroids, 0, math.floor(64+math.sin(self.asteroids_bounce*math.pi)*4)*scaler, 0, scaler, scaler) love.graphics.setFont(Font) for _,element in pairs(self.elements) do element:draw(scale) -- cgit v1.1 From 64adda89b9c1c53827d56391d5ccd9f0e9a4e93c Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 15 Jul 2017 01:00:06 +0200 Subject: Making new win screen based on Menu and SceneManager --- not/Menu.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'not/Menu.lua') diff --git a/not/Menu.lua b/not/Menu.lua index a837045..e0e4064 100644 --- a/not/Menu.lua +++ b/not/Menu.lua @@ -31,6 +31,7 @@ function Menu:new (name) if Menu.sprite == nil then Menu.sprite = love.graphics.newImage("assets/menu.png") end + -- musicPlayer calls should be moved to menu files; see issue with new win screen musicPlayer:setTrack("menu.ogg") musicPlayer:play() self.elements = {} -- cgit v1.1 From e39c00b6e26504ba0f5fc4f0129bfceb3afe331f Mon Sep 17 00:00:00 2001 From: Aki Date: Sun, 16 Jul 2017 17:24:09 +0200 Subject: Fixed MusicPlayer bug with win and pause menus --- not/Menu.lua | 3 --- 1 file changed, 3 deletions(-) (limited to 'not/Menu.lua') diff --git a/not/Menu.lua b/not/Menu.lua index e0e4064..b835777 100644 --- a/not/Menu.lua +++ b/not/Menu.lua @@ -31,9 +31,6 @@ function Menu:new (name) if Menu.sprite == nil then Menu.sprite = love.graphics.newImage("assets/menu.png") end - -- musicPlayer calls should be moved to menu files; see issue with new win screen - musicPlayer:setTrack("menu.ogg") - musicPlayer:play() self.elements = {} self:open(name) end -- cgit v1.1 From 9aa820bf100845da2024bf3af9e802c90b3a6b51 Mon Sep 17 00:00:00 2001 From: Aki Date: Mon, 31 Jul 2017 22:20:41 +0200 Subject: Fixed scaling issues on display change --- not/Menu.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'not/Menu.lua') diff --git a/not/Menu.lua b/not/Menu.lua index b835777..b7fc7ed 100644 --- a/not/Menu.lua +++ b/not/Menu.lua @@ -3,7 +3,6 @@ -- 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. Menu = require "not.Scene":extends() -Menu.scale = getScale() Menu.elements = --[[{not.Element}]]nil Menu.active = 1 Menu.music = --[[not.Music]]nil @@ -79,7 +78,7 @@ function Menu:update (dt) end end function Menu:draw () - local scale = self.scale + local scale = getScale() local scaler = getRealScale() love.graphics.setFont(Font) for _,element in pairs(self.elements) do -- cgit v1.1 From bc625807322a7fc7f16a2c228670c85d292e878f Mon Sep 17 00:00:00 2001 From: Aki Date: Tue, 1 Aug 2017 04:09:45 +0200 Subject: Added short input from taking input --- not/Menu.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'not/Menu.lua') diff --git a/not/Menu.lua b/not/Menu.lua index b7fc7ed..f6da354 100644 --- a/not/Menu.lua +++ b/not/Menu.lua @@ -71,11 +71,22 @@ function Menu:previous () end end +-- @Override +function Menu:isInputDisabled () + if self.inputBreakTimer then + return self.inputDisabled or self.inputBreakTimer > 0 + end + return self.inputDisabled +end + -- LÖVE2D callbacks function Menu:update (dt) for _,element in pairs(self.elements) do element:update(dt) end + if self.inputBreakTimer and self.inputBreakTimer > 0 then + self.inputBreakTimer = self.inputBreakTimer - dt + end end function Menu:draw () local scale = getScale() -- cgit v1.1