diff --git a/assets/entities/nancy/dash_ground1.png b/assets/entities/nancy/dash_ground1.png new file mode 100644 index 0000000..f24e5a6 Binary files /dev/null and b/assets/entities/nancy/dash_ground1.png differ diff --git a/assets/entities/nancy/dash_ground2.png b/assets/entities/nancy/dash_ground2.png new file mode 100644 index 0000000..0f46404 Binary files /dev/null and b/assets/entities/nancy/dash_ground2.png differ diff --git a/data/scripts.lua b/data/scripts.lua index 34b42c3..4d879db 100644 --- a/data/scripts.lua +++ b/data/scripts.lua @@ -17,8 +17,7 @@ require "data/scripts/objects" -- UI functions require "data/scripts/debug" require "data/scripts/keybind" -require "data/scripts/pause" -require "data/scripts/ui/button" +require "data/scripts/ui" -- game loop require "data/scripts/game" require "data/scripts/gameworld" diff --git a/data/scripts/debug.lua b/data/scripts/debug.lua index ad9a3a9..a01fabd 100644 --- a/data/scripts/debug.lua +++ b/data/scripts/debug.lua @@ -32,6 +32,12 @@ function DebugColisions() end function DebugEntities() + for _, particle in pairs(LoadedParticles) do + -- draw center CYAN + love.graphics.setColor(0,1,1) + love.graphics.circle("fill", -Camera.pos.x + particle.pos.x, -Camera.pos.y + particle.pos.y, 1) + + end for _, enty in pairs(LoadedEntities) do -- draw center GREEN love.graphics.setColor(0,1,0) diff --git a/data/scripts/entities/particle.lua b/data/scripts/entities/particle.lua index adc8292..34c3ae8 100644 --- a/data/scripts/entities/particle.lua +++ b/data/scripts/entities/particle.lua @@ -13,8 +13,9 @@ Particle = Entity:New(x,y) o.sprite_scale = particle_data.sprite_scale or o.sprite_scale o.sprite_tint = particle_data.sprite_tint or o.sprite_tint o.sprite_alpha = particle_data.sprite_alpha or o.sprite_alpha - o.sprite_flip = particle_data.sprite_flip or o.sprite_flip + o.sprite_alpha_base = o.sprite_alpha + o.sprite_flip = particle_data.sprite_flip or o.sprite_flip o.animation_active = particle_data.animation_active or false o.time = 0.5 @@ -63,7 +64,7 @@ end function Particle:HandleAnimation() self.body:Animate() self.timer = self.timer + current_dt - self.sprite_alpha = (self.time-self.timer)/self.time + self.sprite_alpha = self.sprite_alpha_base*(self.time-self.timer)/self.time if self.light ~= nil then self.light.range = self.lightRange * self.sprite_alpha/2 end diff --git a/data/scripts/entities/player.lua b/data/scripts/entities/player.lua index 7e3ffa0..0a26b7e 100644 --- a/data/scripts/entities/player.lua +++ b/data/scripts/entities/player.lua @@ -129,6 +129,7 @@ function Player:DoPhysics() local particle_data = { animation = self.body, sprite_tint = HEX2RGB("#fed100"), + sprite_alpha = 0.5, sprite_flip = { x = self.sprite_flip.x, y = self.sprite_flip.y diff --git a/data/scripts/game.lua b/data/scripts/game.lua index ed341b2..ed2ab7a 100644 --- a/data/scripts/game.lua +++ b/data/scripts/game.lua @@ -29,6 +29,4 @@ function GameDraw() DebugColisions() DebugEntities() end - -- pause - if do_pause then PauseUI() end end diff --git a/data/scripts/pause.lua b/data/scripts/pause.lua deleted file mode 100644 index adae5b1..0000000 --- a/data/scripts/pause.lua +++ /dev/null @@ -1,66 +0,0 @@ -function PauseUI() - -- Set scale to 1 - love.graphics.scale(0.5,0.5) - -- Parameters - local pauseWidth = 640 - local pauseHeight = 480 - local pauseX = (game.width/2)-(pauseWidth/2) - local pauseY = (game.height/2)-(pauseHeight/2) - local mouse_x, mouse_y = love.mouse.getPosition() - -- Base items - love.graphics.setColor(0,0,0,0.3) - love.graphics.rectangle("fill", 0, 0, game.width, game.height) - love.graphics.setColor(1,1,1,1) - love.graphics.rectangle("fill", pauseX, pauseY, pauseWidth, pauseHeight) - -- Buttons - for _, element in pairs(UIElement) do - element:Draw() - end - - -- Reset scale - love.graphics.scale(2,2) -end - -function MenuStep(menu) - -- first get mouse - local mouse_x, mouse_y = love.mouse.getPosition() - for _, element in pairs(UIElement) do - if element.type == "Button" then - element:checkMouse(mouse_x, mouse_y) - end - end - if menu == "pauseMenu" then - if PauseResume:getVariable() == true then - MenuExit(menu,0) - do_pause = false - elseif PauseExit:getVariable() == true then - love.event.quit() - end - else - - end -end - -function MenuExit(from,to) - for _, element in pairs(UIElement) do - element = nil - end - UIElement = {} - if from == "pauseMenu" then - PauseResume = nil - PauseOptions = nil - PauseExit = nil - end - menuPage = to or nil -end - -function MenuInit(menu) - local buttonStandard = {width = 200, height = 30, separation = 10} - -- main menu - if menu == "pauseMenu" then - -- elements - PauseResume = interfaceButton:New(game.width/2, game.height/2-buttonStandard.height-buttonStandard.separation, buttonStandard.width, buttonStandard.height, {false,true}, 1, {text = "Resume", color = {0,0,0.5}, color2 = {1,1,1}}) - PauseOptions = interfaceButton:New(game.width/2, game.height/2, buttonStandard.width, buttonStandard.height, {false,true}, 1, {text = "Options", color = {0,0,0.5}, color2 = {1,1,1}}) - PauseExit = interfaceButton:New(game.width/2, game.height/2+buttonStandard.height+buttonStandard.separation, buttonStandard.width, buttonStandard.height, {false,true}, 1, {text = "Exit", color = {0,0,0.5}, color2 = {1,1,1}}) - end -end diff --git a/data/scripts/ui.lua b/data/scripts/ui.lua new file mode 100644 index 0000000..80a0eb2 --- /dev/null +++ b/data/scripts/ui.lua @@ -0,0 +1,104 @@ +function MenuDraw(menu) + -- Set scale to 1 + love.graphics.scale(0.5,0.5) + if menu == "pauseMenu" then + -- Parameters + local pauseWidth = 640 + local pauseHeight = 480 + local pauseX = (game.width/2)-(pauseWidth/2) + local pauseY = (game.height/2)-(pauseHeight/2) + local mouse_x, mouse_y = love.mouse.getPosition() + -- Base items + love.graphics.setColor(0,0,0,0.3) + love.graphics.rectangle("fill", 0, 0, game.width, game.height) + love.graphics.setColor(1,1,1,1) + love.graphics.rectangle("fill", pauseX, pauseY, pauseWidth, pauseHeight) + -- Reset scale + end + for _, element in pairs(UIElement) do + element:Draw() + end + love.graphics.scale(2,2) +end + +function MenuStep(menu) + -- first get mouse + local mouse_x, mouse_y = love.mouse.getPosition() + for _, element in pairs(UIElement) do + if element.type == "Button" then + element:checkMouse(mouse_x, mouse_y) + end + end + if menu == "pauseMenu" then + if PauseResume:getVariable() == true then + MenuExit(menu,0) + do_pause = false + elseif PauseExit:getVariable() == true then + love.event.quit() + end + else + + end +end + +function MenuExit(from,to) + for _, element in pairs(UIElement) do + element = nil + end + UIElement = {} + if from == "pauseMenu" then + PauseResume = nil + PauseOptions = nil + PauseExit = nil + end + menuPage = to or nil +end + +function MenuInit(menu) + local buttonStandard = {width = 200, height = 30, separation = 10} + -- main menu + if menu == "pauseMenu" then + -- elements + PauseResume = interfaceButton:New( + game.width/2, + game.height/2-buttonStandard.height-buttonStandard.separation, + buttonStandard.width, + buttonStandard.height, + {false,true}, + 1, + { + text = "Resume", + color = {0,0,0.5}, + color2 = {1,1,1} + } + ) + PauseOptions = interfaceButton:New( + game.width/2, + game.height/2, + buttonStandard.width, + buttonStandard.height, + {false,true}, + 1, + { + text = "Options", + color = {0,0,0.5}, + color2 = {1,1,1} + } + ) + PauseExit = interfaceButton:New( + game.width/2, + game.height/2+buttonStandard.height+buttonStandard.separation, + buttonStandard.width, + buttonStandard.height, + {false,true}, + 1, + { + text = "Exit", + color = {0,0,0.5}, + color2 = {1,1,1} + } + ) + end +end + +require "data/scripts/ui/button" diff --git a/main.lua b/main.lua index f1ba07e..de0e310 100644 --- a/main.lua +++ b/main.lua @@ -66,8 +66,6 @@ function love.update(dt) fps_count = fps_count + 1 current_dt = dt - --MenuStep - MenuStep(menuPage) --keypressed if Keybind:HasPressed(Keybind.menu.pause) then if do_pause then @@ -75,10 +73,12 @@ function love.update(dt) else menuPage = "pauseMenu" MenuInit(menuPage) - do_pause = true end end + --MenuStep + if menuPage ~= nil then MenuStep(menuPage) end + if Keybind:HasPressed(Keybind.debug.debug) then if debug then debug = false @@ -137,5 +137,8 @@ function love.draw() else GameDraw() end + + if menuPage ~= nil then MenuDraw(menuPage) end + love.graphics.print(arrow,10,40) end