parent
bcada33441
commit
19e10d6601
@ -1,14 +1,21 @@ |
||||
function GameKeyPressed(key) |
||||
|
||||
if key == "escape" then |
||||
_G.GAMESTATE = "MENU" |
||||
print("STATE CHANEGD: MENU!") |
||||
musicBattle:setVolume(0) |
||||
musicPause:setVolume(0.5) |
||||
|
||||
_G.GAMESTATE = "PAUSE" |
||||
print("STATE CHANEGD: PAUSED!") |
||||
_G.PAUSED = true |
||||
end |
||||
|
||||
if key == "b" then |
||||
if key == "b" and not _G.PAUSED then |
||||
DebugFlag = not DebugFlag |
||||
end |
||||
|
||||
if key == "r" then |
||||
--[[ |
||||
if key == "r" and not _G.PAUSED then |
||||
love.load() |
||||
end |
||||
]]-- |
||||
end |
||||
|
@ -0,0 +1,45 @@ |
||||
local function button(x,y, w, h, text, selected) |
||||
--x,y is the top left corner of the button |
||||
local rounding = 30 -- used for rounding the buttons |
||||
|
||||
if not selected then |
||||
love.graphics.setColor(love.math.colorFromBytes(41,134,204)) |
||||
elseif selected then |
||||
love.graphics.setColor(love.math.colorFromBytes(244,67,54)) |
||||
end |
||||
-- Draw rectangle |
||||
love.graphics.rectangle("fill", x, y, w, h, rounding, rounding) |
||||
|
||||
-- Get width and height of text |
||||
local tw = MenuFont:getWidth(text) |
||||
local th = MenuFont:getHeight(text) |
||||
-- Calculate position to center the text |
||||
local textX = x + (w - tw) / 2 |
||||
local textY = y + (h - th) / 2 |
||||
-- Place text inside the rectangle |
||||
love.graphics.setFont(MenuFont) |
||||
love.graphics.setColor(1,1,1) -- reset colours |
||||
love.graphics.print(text, textX, textY) |
||||
end |
||||
|
||||
|
||||
function DrawPause() |
||||
local opacity = 0.3 |
||||
local height = love.graphics.getHeight() |
||||
local width = love.graphics.getWidth() |
||||
local bwidth, bheight = 300, 140 |
||||
love.graphics.setFont(GameFont) |
||||
|
||||
DrawGame() --Draw a single frame of the game |
||||
love.graphics.setColor(0.1,0.1,0.1, opacity) --overlay opaque img |
||||
love.graphics.rectangle("fill", 0, 0, width, height) |
||||
|
||||
love.graphics.setColor(1,1,1) |
||||
love.graphics.print("PAUSED", 100,100) |
||||
--love.graphics.print("" .. PAUSE_POS, 200,200) |
||||
|
||||
button(100, 200, bwidth, bheight, "Return", PAUSE_POS == 0 and true or false) |
||||
button(100, 350, bwidth, bheight, "Menu", PAUSE_POS == 1 and true or false) |
||||
button(100, 500, bwidth, bheight, "Quit", PAUSE_POS == 2 and true or false) |
||||
love.graphics.setColor(255,255,255) -- reset colours |
||||
end |
@ -0,0 +1,44 @@ |
||||
function PauseKeyPressed(key) |
||||
if key == 'return' then |
||||
musicBattle:setVolume(0.5) |
||||
musicPause:setVolume(0) |
||||
-- 0 Return to game |
||||
-- 1 Quit |
||||
if PAUSE_POS == 0 then |
||||
-- unpause the game |
||||
_G.GAMESTATE = "GAME" |
||||
print("STATE CHANEGD: GAME!") |
||||
_G.PAUSED = false |
||||
musicBattle:setVolume(0.5) |
||||
musicPause:setVolume(0) |
||||
|
||||
elseif PAUSE_POS == 1 then |
||||
_G.GAMESTATE = "MENU" |
||||
print("STATE CHANEGD: MENU!") |
||||
_G.PAUSED = false |
||||
musicPause:stop() |
||||
musicBattle:stop() |
||||
|
||||
elseif PAUSE_POS == 2 then |
||||
love.event.quit() |
||||
end |
||||
|
||||
end |
||||
|
||||
|
||||
if love.keyboard.isDown("up") then |
||||
if _G.PAUSE_POS == 0 then |
||||
_G.PAUSE_POS = 0 |
||||
else |
||||
_G.PAUSE_POS = _G.PAUSE_POS - 1 |
||||
end |
||||
end |
||||
|
||||
if love.keyboard.isDown("down") then |
||||
if _G.PAUSE_POS >= _G.PAUSE_MAX then |
||||
_G.PAUSE_POS = _G.PAUSE_MAX |
||||
else |
||||
_G.PAUSE_POS = _G.PAUSE_POS + 1 |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,2 @@ |
||||
function UpdatePause(dt) |
||||
end |
@ -1,3 +1,8 @@ |
||||
GAMESTATE = "MENU" |
||||
|
||||
MENU_POS = 0 |
||||
MENU_MAX = 3 |
||||
MENU_MAX = 3 --0 play, 1 ?, 2 ?, 3 quit |
||||
|
||||
PAUSED = false |
||||
PAUSE_POS = 0 |
||||
PAUSE_MAX = 2 -- 0 resume, 1 menu, 2 quit |
@ -0,0 +1,68 @@ |
||||
-- |
||||
-- classic |
||||
-- |
||||
-- Copyright (c) 2014, rxi |
||||
-- |
||||
-- This module is free software; you can redistribute it and/or modify it under |
||||
-- the terms of the MIT license. See LICENSE for details. |
||||
-- |
||||
|
||||
|
||||
local Object = {} |
||||
Object.__index = Object |
||||
|
||||
|
||||
function Object:new() |
||||
end |
||||
|
||||
|
||||
function Object:extend() |
||||
local cls = {} |
||||
for k, v in pairs(self) do |
||||
if k:find("__") == 1 then |
||||
cls[k] = v |
||||
end |
||||
end |
||||
cls.__index = cls |
||||
cls.super = self |
||||
setmetatable(cls, self) |
||||
return cls |
||||
end |
||||
|
||||
|
||||
function Object:implement(...) |
||||
for _, cls in pairs({...}) do |
||||
for k, v in pairs(cls) do |
||||
if self[k] == nil and type(v) == "function" then |
||||
self[k] = v |
||||
end |
||||
end |
||||
end |
||||
end |
||||
|
||||
|
||||
function Object:is(T) |
||||
local mt = getmetatable(self) |
||||
while mt do |
||||
if mt == T then |
||||
return true |
||||
end |
||||
mt = getmetatable(mt) |
||||
end |
||||
return false |
||||
end |
||||
|
||||
|
||||
function Object:__tostring() |
||||
return "Object" |
||||
end |
||||
|
||||
|
||||
function Object:__call(...) |
||||
local obj = setmetatable({}, self) |
||||
obj:new(...) |
||||
return obj |
||||
end |
||||
|
||||
|
||||
return Object |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue