From 8f7cb0f930325967799d49592fd7e8367855cc38 Mon Sep 17 00:00:00 2001 From: 1029chris <1029chris@gmail.com> Date: Fri, 24 Jun 2016 16:40:28 -0700 Subject: Added pause menu when you press Escape --- assets.lua | 1 + assets/pause.png | Bin 0 -> 4363 bytes loading.lua | 14 ++++++++++++++ main.lua | 33 +++++++++++++++------------------ var.lua | 3 +++ 5 files changed, 33 insertions(+), 18 deletions(-) create mode 100644 assets/pause.png diff --git a/assets.lua b/assets.lua index f489eae..1d19f99 100644 --- a/assets.lua +++ b/assets.lua @@ -246,6 +246,7 @@ function loadAssets(id) if id == 18 then bsod = {} bsod.pic = love.graphics.newImage("assets/bsod.png") + pause.pic = love.graphics.newImage("assets/pause.png") end if id == 19 then loaded = true diff --git a/assets/pause.png b/assets/pause.png new file mode 100644 index 0000000..4db879b Binary files /dev/null and b/assets/pause.png differ diff --git a/loading.lua b/loading.lua index 5596649..db36706 100644 --- a/loading.lua +++ b/loading.lua @@ -33,3 +33,17 @@ function drawBSOD() loadRe() end end +function drawPause() + love.graphics.setBackgroundColor(0,0,120) + love.graphics.setColor(256,256,256) + love.graphics.draw(pause.pic, sys.w/2, sys.h/2, 0, 1, 1, 320, 200) + if love.keyboard.isDown("return") == true then + love.event.quit() + end + if love.keyboard.isDown("escape") == true and pause.esc == false then + love.audio.resume() + pause.esc = true + pause.p = false + love.graphics.setBackgroundColor(0, 128, 128) + end +end diff --git a/main.lua b/main.lua index 6b715a7..fcce55e 100644 --- a/main.lua +++ b/main.lua @@ -30,29 +30,21 @@ function love.update(dt) minim = sys.h+10 sys.mouse.x = love.mouse.getX() sys.mouse.y = love.mouse.getY() - if love.keyboard.isDown("escape") == true then - love.event.quit() - end - if love.keyboard.isDown("f4") == true then - love.window.setMode(800, 600, {fullscreen=true, fullscreentype="desktop"}) - for i=1,#win do - win[i].update = true - end - elseif love.keyboard.isDown("f5") == true then - love.window.setMode(1280,720,{fullscreen=true, fullscreentype="exclusive"}) - for i=1,#win do - win[i].update = true - end + if love.keyboard.isDown("escape") == true and pause.esc == false and loaded == true and pause.p == false then + love.audio.pause() + pause.esc = true + pause.p = true + sys.mouse.p.p = false end - if fade == 1 and fadeOpacity < 255 then + if fade == 1 and fadeOpacity < 255 and pause.p == false then fadeOpacity = fadeOpacity + 5 - elseif fade == 0 and fadeOpacity > 0 then + elseif fade == 0 and fadeOpacity > 0 and pause.p == false then fadeOpacity = fadeOpacity - 5 end - if scene == 1 then + if scene == 1 and pause.p == false then updateSystem(dt) end - if loaded == true then + if loaded == true and pause.p == false then if v1.yes == true and v1.complete == false then v1.timer = v1.timer + dt end @@ -89,6 +81,9 @@ function love.keyreleased(key) v1.c.health = v1.c.health - 5 v1.spm = v1.spm + 0.5*(sys.h/1080) end + if key == "escape" then + pause.esc = false + end end function love.mousereleased(x, y, button) if scene ~= 0 then @@ -105,7 +100,9 @@ function love.mousereleased(x, y, button) end end function love.draw() - if scene == 1 then + if pause.p == true then + drawPause() + elseif scene == 1 then drawSystem() elseif scene == 0 then drawLoading() diff --git a/var.lua b/var.lua index eb74f23..6e4a4d4 100644 --- a/var.lua +++ b/var.lua @@ -299,6 +299,9 @@ function loadPre() loadingId = 1 time = 0 fadeOpacity = 0 + pause = {} + pause.p = false + pause.esc = false sys = {} sys.s = 0 sys.mouse = {} -- cgit