aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author1029chris <1029chris@gmail.com>2016-06-24 16:40:28 -0700
committer1029chris <1029chris@gmail.com>2016-06-24 16:40:28 -0700
commit8f7cb0f930325967799d49592fd7e8367855cc38 (patch)
tree836bb612458a43b5173904cd7cb47d2026b204fe
parenta18b64a082a7dd26d3ed8eb5462058bde80a4b40 (diff)
Added pause menu when you press Escape
-rw-r--r--assets.lua1
-rw-r--r--assets/pause.pngbin0 -> 4363 bytes
-rw-r--r--loading.lua14
-rw-r--r--main.lua33
-rw-r--r--var.lua3
5 files changed, 33 insertions, 18 deletions
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
--- /dev/null
+++ b/assets/pause.png
Binary files 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 = {}