@@ -5,7 +5,16 @@ local thrusterMax = 0 | |||||
local animationComplete = false | local animationComplete = false | ||||
local frame = 0 | local frame = 0 | ||||
asteroidImage = love.graphics.newImage("entities/planet/asteroid.png") | asteroidImage = love.graphics.newImage("entities/planet/asteroid.png") | ||||
function love.keyreleased(key) | |||||
if key == "escape" and gameStatus == "play" then | |||||
if pauseStatus then | |||||
pauseStatus = false | |||||
else pauseStatus = true | |||||
end | |||||
end | |||||
end | |||||
function levelgeneral.update(dt) | function levelgeneral.update(dt) | ||||
if not pauseStatus then | |||||
if not levelLoaded then | if not levelLoaded then | ||||
level = require("levels/level" .. currentLevel) | level = require("levels/level" .. currentLevel) | ||||
level.load() | level.load() | ||||
@@ -63,7 +72,7 @@ else | |||||
camera:follow(VCAM.x, VCAM.y) | camera:follow(VCAM.x, VCAM.y) | ||||
end | end | ||||
levelgeneral.GUIControl() | levelgeneral.GUIControl() | ||||
end | |||||
end | end | ||||
function levelgeneral.draw() | function levelgeneral.draw() | ||||
@@ -129,10 +138,12 @@ function levelgeneral.draw() | |||||
love.graphics.rectangle("fill",0, WINDOW_HEIGHT-50, firstShip.fuel/2, n) | love.graphics.rectangle("fill",0, WINDOW_HEIGHT-50, firstShip.fuel/2, n) | ||||
love.graphics.setColor(1,1,1,1) | love.graphics.setColor(1,1,1,1) | ||||
guimenu:butt(playbutts, WINDOW_WIDTH, WINDOW_HEIGHT, 1100, WINDOW_HEIGHT-50, 40, WINDOW_WIDTH/3) | guimenu:butt(playbutts, WINDOW_WIDTH, WINDOW_HEIGHT, 1100, WINDOW_HEIGHT-50, 40, WINDOW_WIDTH/3) | ||||
love.keyboard.mouseisReleased = false | |||||
end | end | ||||
end | end | ||||
if pauseStatus then | |||||
drawPauseMenu() | |||||
love.keyboard.mouseisReleased = false | |||||
end | |||||
@@ -39,6 +39,7 @@ function love.load() | |||||
print(love.filesystem.areSymlinksEnabled()) | print(love.filesystem.areSymlinksEnabled()) | ||||
print(love.filesystem.createDirectory('.')) | print(love.filesystem.createDirectory('.')) | ||||
love.filesystem.newFile("File") | love.filesystem.newFile("File") | ||||
pauseMake() | |||||
testwalls = love.filesystem.load("save") | testwalls = love.filesystem.load("save") | ||||
if testwalls ~= nil then | if testwalls ~= nil then | ||||
saveData = love.filesystem.load("save")() | saveData = love.filesystem.load("save")() | ||||
@@ -27,3 +27,5 @@ If you're on arch, install the prerequisites with: | |||||
Changelog: | Changelog: | ||||
- Changed practice scoring system | - Changed practice scoring system | ||||
- Fixed bug with cannon timers not resetting | - Fixed bug with cannon timers not resetting | ||||
- Toggle music button added | |||||
- Added the pause menu |
@@ -16,8 +16,13 @@ function buttonClutter() | |||||
DIFFERENCE_Y = myscreen.d | DIFFERENCE_Y = myscreen.d | ||||
OFFSET_X = myscreen.e | OFFSET_X = myscreen.e | ||||
OFFSET_Y = myscreen.f | OFFSET_Y = myscreen.f | ||||
end | |||||
end)) | |||||
table.insert(buttons, menu:addButton("Toggle Music", | |||||
function() | |||||
toggleMusic() | |||||
end | |||||
)) | )) | ||||
table.insert(buttons, menu:addButton("Quit", | table.insert(buttons, menu:addButton("Quit", | ||||
function() | function() | ||||
love.event.quit() | love.event.quit() | ||||
@@ -8,6 +8,7 @@ require 'entities/planet/planet' | |||||
require 'src/buttonClutter' | require 'src/buttonClutter' | ||||
require 'entities/explosion/explosion' | require 'entities/explosion/explosion' | ||||
require 'src/GUI' | require 'src/GUI' | ||||
require 'src/pauseMenu' | |||||
require 'src/stateMachine' | require 'src/stateMachine' | ||||
require 'entities/base/base' | require 'entities/base/base' | ||||
require 'entities/camera/VCAM' | require 'entities/camera/VCAM' | ||||
@@ -12,41 +12,61 @@ music = { | |||||
} | } | ||||
mute = false | mute = false | ||||
function musicController(orders, toggling) | function musicController(orders, toggling) | ||||
if (orders == 'norm' and not mute and not reachedGoal) then | |||||
if (orders == 'norm' and not reachedGoal) then | |||||
if (gameState == 'menu' or gameState == "selectlv") then | if (gameState == 'menu' or gameState == "selectlv") then | ||||
music['menu']:play() | music['menu']:play() | ||||
music["play"]:play() | music["play"]:play() | ||||
music["play"]:setVolume(0) | |||||
music["menu"]:setVolume(1) | |||||
if mute then | |||||
music["menu"]:setVolume(0) | |||||
music["play"]:setVolume(0) | |||||
else | |||||
--print("music") | |||||
music["play"]:setVolume(0) | |||||
music["menu"]:setVolume(1) | |||||
end | |||||
elseif gameStatus == 'play' then | elseif gameStatus == 'play' then | ||||
music["play"]:play() | music["play"]:play() | ||||
if mute then | |||||
music["menu"]:setVolume(0) | |||||
music["play"]:setVolume(0) | |||||
else | |||||
music["play"]:setVolume(0.8) | music["play"]:setVolume(0.8) | ||||
music["menu"]:setVolume(0.2) | music["menu"]:setVolume(0.2) | ||||
end | |||||
elseif gameStatus == 'setup' then | elseif gameStatus == 'setup' then | ||||
music['menu']:play() | music['menu']:play() | ||||
music["play"]:play() | music["play"]:play() | ||||
if mute then | |||||
music["menu"]:setVolume(0) | |||||
music["play"]:setVolume(0) | |||||
else | |||||
music["play"]:setVolume(0.6) | music["play"]:setVolume(0.6) | ||||
music["menu"]:setVolume(1) | music["menu"]:setVolume(1) | ||||
end | |||||
elseif orders == "mute" then | |||||
if toggling == 1 then | |||||
mute = true | |||||
else | |||||
mute = false | |||||
end | |||||
end | end | ||||
elseif orders == "click" then | elseif orders == "click" then | ||||
-- print("entities/camera/button0" .. math.random(1, 5)..".mp3.flac") | -- print("entities/camera/button0" .. math.random(1, 5)..".mp3.flac") | ||||
local tempClick = love.audio.newSource("entities/camera/button0" .. math.random(1, 5)..".mp3.flac", "static") | local tempClick = love.audio.newSource("entities/camera/button0" .. math.random(1, 5)..".mp3.flac", "static") | ||||
tempClick:stop() | |||||
tempClick:play() | tempClick:play() | ||||
end | end | ||||
end | end | ||||
function stopSounds() | function stopSounds() | ||||
for i, sound in ipairs(sounds) do | for i, sound in ipairs(sounds) do | ||||
sound[i]:stop() | sound[i]:stop() | ||||
print("stopping sounds") | |||||
--print("stopping sounds") | |||||
end | end | ||||
end | end | ||||
function stopMusic() | function stopMusic() | ||||
music["play"]:setVolume(0) | music["play"]:setVolume(0) | ||||
music["menu"]:setVolume(0) | music["menu"]:setVolume(0) | ||||
end | |||||
end | |||||
function toggleMusic() | |||||
if mute then | |||||
mute = false | |||||
else | |||||
mute = true | |||||
--print("switch") | |||||
end | |||||
end |
@@ -0,0 +1,38 @@ | |||||
pauseStatus = false | |||||
pauseMenu = {} | |||||
function pauseMake() | |||||
table.insert(pauseMenu, menu:addButton("Resume", | |||||
function() | |||||
pauseStatus = false | |||||
end | |||||
)) | |||||
table.insert(pauseMenu, menu:addButton("Main Menu", | |||||
function() | |||||
pauseStatus = false | |||||
goBack() | |||||
end | |||||
)) | |||||
table.insert(pauseMenu, menu:addButton("Toggle Fullscreen", | |||||
function() | |||||
myscreen:toggle(WINDOW_HEIGHT, WINDOW_WIDTH) | |||||
DIFFERENCE_X = myscreen.c | |||||
DIFFERENCE_Y = myscreen.d | |||||
OFFSET_X = myscreen.e | |||||
OFFSET_Y = myscreen.f | |||||
end | |||||
)) | |||||
table.insert(pauseMenu, menu:addButton("Toggle Music", | |||||
function() | |||||
toggleMusic() | |||||
end | |||||
)) | |||||
table.insert(pauseMenu, menu:addButton("Quit", | |||||
function() | |||||
love.event.quit() | |||||
end | |||||
)) | |||||
end | |||||
function drawPauseMenu() | |||||
-- print("draw") | |||||
menu:butt(pauseMenu, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH/2, WINDOW_HEIGHT/2, 40, WINDOW_WIDTH/3) | |||||
end |
@@ -3,13 +3,12 @@ print("levels/"..gameState) | |||||
function stateUpdate(dt) | function stateUpdate(dt) | ||||
state = require("levels/"..gameState) | state = require("levels/"..gameState) | ||||
state.update(dt) | state.update(dt) | ||||
if love.keyboard.isDown('escape') then | |||||
love.event.quit() | |||||
end | |||||
musicController("norm") | musicController("norm") | ||||
end | end | ||||
function goBack() | |||||
state.goBack() | |||||
end | |||||
function stateDraw() | function stateDraw() | ||||
state.draw() | state.draw() | ||||
end | end |