Menu additions and Function
- Menu now has buttons - Menu buttons will change color when hovered over - Menu "start" button now changes stage to the Game Test
This commit is contained in:
parent
f68115733e
commit
e9da50897f
6 changed files with 123 additions and 11 deletions
9
main.lua
9
main.lua
|
|
@ -8,14 +8,15 @@ functiongenerator = {}
|
|||
check_space = {}
|
||||
|
||||
function love.load()
|
||||
window = {}
|
||||
window.x, window.y = love.window.getDesktopDimensions()
|
||||
math.randomseed(os.time())
|
||||
Scene = "menu"
|
||||
inputs_ini = require('scripts/inputs')
|
||||
physics_ini = require('physics')
|
||||
menu_ini = require('menu')
|
||||
menu.load()
|
||||
window = {}
|
||||
NPCs = {}
|
||||
window.x, window.y = love.window.getDesktopDimensions()
|
||||
ground = {
|
||||
x = 0,
|
||||
y = window.y,
|
||||
|
|
@ -52,7 +53,9 @@ function love.update(dt)
|
|||
end
|
||||
|
||||
function love.draw()
|
||||
if Scene == "gameTest" then
|
||||
love.graphics.print(Scene, 100, 100)
|
||||
if Scene == "gameTest" then
|
||||
if love.graphics.getColor() ~= 1 then love.graphics.setColor(1, 1, 1) end
|
||||
love.graphics.rectangle("line", player.x, player.y, player.width, player.height)
|
||||
if player.bools.isFacingRight then
|
||||
love.graphics.rectangle("line", player.x+10, player.y-20, 20, 20)
|
||||
|
|
|
|||
104
menu.lua
104
menu.lua
|
|
@ -1,38 +1,128 @@
|
|||
menu = {}
|
||||
menu = {
|
||||
subScene = "intro"
|
||||
}
|
||||
menuButtons = {
|
||||
Start = {},
|
||||
Settings = {},
|
||||
Quit = {}
|
||||
}
|
||||
font_ini = require('scripts/fonts')
|
||||
function menu.load()
|
||||
RGB = 1
|
||||
RGB_hover = 0.5
|
||||
titleCard = {
|
||||
duration = false,
|
||||
mainTitle = {
|
||||
text = love.graphics.newText(Effexor_Intro, "Void Shot"),
|
||||
intro_text = love.graphics.newText(Effexor_Intro, "Void Shot"),
|
||||
main_text = love.graphics.newText(Effexor_menu, "Void Shot"),
|
||||
y = 250,
|
||||
fallingRate = 2
|
||||
},
|
||||
secondTitle = {
|
||||
text = love.graphics.newText(ScratchedCarPaint_Intro, "Endless Desert"),
|
||||
intro_text = love.graphics.newText(ScratchedCarPaint_Intro, "Endless Desert"),
|
||||
main_text = love.graphics.newText(ScratchedCarPaint_menu, "Endless Desert"),
|
||||
y = 500,
|
||||
fallingRate = 2
|
||||
},
|
||||
targetTime = 1,
|
||||
elapsedTime = 0
|
||||
}
|
||||
menuButtons = {
|
||||
Start = {
|
||||
x = window.x/2 - 100,
|
||||
y = window.y / 2 - 200,
|
||||
width = 200,
|
||||
height = 75,
|
||||
text = love.graphics.newText(Effexor_buttons, "Enter")
|
||||
},
|
||||
Settings = {
|
||||
x = window.x/2 - 100,
|
||||
y = window.y / 2,
|
||||
width = 200,
|
||||
height = 75,
|
||||
text = love.graphics.newText(Effexor_buttons, "Settings")
|
||||
},
|
||||
Quit = {
|
||||
x = window.x/2 - 100,
|
||||
y = window.y / 2 + 200,
|
||||
width = 200,
|
||||
height = 75,
|
||||
text = love.graphics.newText(Effexor_buttons, "Abandon")
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
function menu.update(dt)
|
||||
if titleCard.duration == true then
|
||||
titleCardUpdate(dt)
|
||||
if titleCard.elapsedTime >= titleCard.targetTime then
|
||||
menu.subScene = "main"
|
||||
RGB = 1
|
||||
titleCard.mainTitle.y = 0
|
||||
titleCard.secondTitle.y = 100
|
||||
titleCard.duration = false
|
||||
titleCard.elapsedTime = 0
|
||||
titleCard.targetTime = 1
|
||||
end
|
||||
end
|
||||
if menu.subScene == "main" and love.mouse.isDown(1) then
|
||||
if mouseOver(menuButtons.Start) then menu.subScene = "end" end
|
||||
if mouseOver(menuButtons.Settings) then menu.subScene = "settings" end
|
||||
if mouseOver(menuButtons.Quit) then menu.subScene = "exit" end
|
||||
end
|
||||
if menu.subScene == "end" then
|
||||
if titleCard.elapsedTime < titleCard.targetTime then
|
||||
titleCard.elapsedTime = titleCard.elapsedTime + love.timer.getDelta()
|
||||
else
|
||||
Scene = "gameTest"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function menu.draw()
|
||||
love.graphics.setColor(RGB, RGB, RGB)
|
||||
love.graphics.draw(titleCard.mainTitle.text, window.x/2 - titleCard.mainTitle.text:getDimensions()/2, titleCard.mainTitle.y)
|
||||
love.graphics.draw(titleCard.secondTitle.text, window.x/2 - titleCard.secondTitle.text:getDimensions()*0.5/2, titleCard.secondTitle.y, 0, 0.5, 0.65)
|
||||
love.graphics.print(menu.subScene, 100, 200)
|
||||
if menu.subScene == "intro" then
|
||||
love.graphics.setColor(RGB, RGB, RGB)
|
||||
love.graphics.draw(titleCard.mainTitle.intro_text, window.x/2 - titleCard.mainTitle.intro_text:getDimensions()/2, titleCard.mainTitle.y)
|
||||
love.graphics.draw(titleCard.secondTitle.intro_text, window.x/2 - titleCard.secondTitle.intro_text:getDimensions()*0.5/2, titleCard.secondTitle.y, 0, 0.5, 0.65)
|
||||
elseif menu.subScene == "main" then
|
||||
love.graphics.setColor(RGB, RGB, RGB)
|
||||
love.graphics.draw(titleCard.mainTitle.main_text, window.x/2 - titleCard.mainTitle.main_text:getDimensions()/2, titleCard.mainTitle.y)
|
||||
love.graphics.draw(titleCard.secondTitle.main_text, window.x/2 - titleCard.secondTitle.main_text:getDimensions()*0.5/2, titleCard.secondTitle.y, 0, 0.5, 0.65)
|
||||
|
||||
-- buttons
|
||||
if mouseOver(menuButtons.Start) then love.graphics.setColor(RGB_hover, RGB_hover, RGB_hover) else love.graphics.setColor(RGB, RGB, RGB) end
|
||||
love.graphics.draw(menuButtons.Start.text, menuButtons.Start.x, menuButtons.Start.y)
|
||||
love.graphics.rectangle("line", menuButtons.Start.x, menuButtons.Start.y, menuButtons.Start.width, menuButtons.Start.height)
|
||||
|
||||
if mouseOver(menuButtons.Settings) then love.graphics.setColor(RGB_hover, RGB_hover, RGB_hover) else love.graphics.setColor(RGB, RGB, RGB) end
|
||||
love.graphics.draw(menuButtons.Settings.text, menuButtons.Settings.x, menuButtons.Settings.y)
|
||||
love.graphics.rectangle("line", menuButtons.Settings.x, menuButtons.Settings.y, menuButtons.Settings.width, menuButtons.Settings.height)
|
||||
|
||||
if mouseOver(menuButtons.Quit) then love.graphics.setColor(RGB_hover, RGB_hover, RGB_hover) else love.graphics.setColor(RGB, RGB, RGB) end
|
||||
love.graphics.draw(menuButtons.Quit.text, menuButtons.Quit.x, menuButtons.Quit.y)
|
||||
love.graphics.rectangle("line", menuButtons.Quit.x, menuButtons.Quit.y, menuButtons.Quit.width, menuButtons.Quit.height)
|
||||
love.graphics.setColor(RGB, RGB, RGB)
|
||||
elseif menu.subScene == "end" then
|
||||
love.graphics.setColor(1,0,0)
|
||||
|
||||
love.graphics.draw(titleCard.mainTitle.main_text, window.x/2 - titleCard.mainTitle.main_text:getDimensions()/2, titleCard.mainTitle.y)
|
||||
love.graphics.draw(titleCard.secondTitle.main_text, window.x/2 - titleCard.secondTitle.main_text:getDimensions()*0.5/2, titleCard.secondTitle.y, 0, 0.5, 0.65)
|
||||
|
||||
love.graphics.draw(menuButtons.Start.text, menuButtons.Start.x, menuButtons.Start.y)
|
||||
love.graphics.rectangle("line", menuButtons.Start.x, menuButtons.Start.y, menuButtons.Start.width, menuButtons.Start.height)
|
||||
|
||||
love.graphics.draw(menuButtons.Settings.text, menuButtons.Settings.x, menuButtons.Settings.y)
|
||||
love.graphics.rectangle("line", menuButtons.Settings.x, menuButtons.Settings.y, menuButtons.Settings.width, menuButtons.Settings.height)
|
||||
|
||||
love.graphics.draw(menuButtons.Quit.text, menuButtons.Quit.x, menuButtons.Quit.y)
|
||||
love.graphics.rectangle("line", menuButtons.Quit.x, menuButtons.Quit.y, menuButtons.Quit.width, menuButtons.Quit.height)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
function titleCardUpdate(dt)
|
||||
if RGB > 0.001 then
|
||||
if RGB > 0 then
|
||||
titleCard.elapsedTime = titleCard.elapsedTime + dt
|
||||
RGB = 1 - (titleCard.elapsedTime/titleCard.targetTime)
|
||||
print(RGB)
|
||||
|
|
|
|||
|
|
@ -2,5 +2,6 @@ CloisterBlackLight = love.graphics.newFont("GFX/fonts/CloisterBlackLight-axjg.tt
|
|||
Dearkatie = love.graphics.newFont("GFX/fonts/Dearkatienbp-nZeg.ttf", 20)
|
||||
Effexor_Intro = love.graphics.newFont("GFX/fonts/Effexor-AEm.ttf", 250)
|
||||
Effexor_menu = love.graphics.newFont("GFX/fonts/Effexor-AEm.ttf", 100)
|
||||
Effexor_buttons = love.graphics.newFont("GFX/fonts/Effexor-AEm.ttf", 50)
|
||||
ScratchedCarPaint_Intro = love.graphics.newFont("GFX/fonts/ScratchedCarPaint-Kd57.ttf", 100)
|
||||
ScratchedCarPaint = love.graphics.newFont("GFX/fonts/ScratchedCarPaint-Kd57.ttf", 50)
|
||||
ScratchedCarPaint_menu = love.graphics.newFont("GFX/fonts/ScratchedCarPaint-Kd57.ttf", 50)
|
||||
10
scripts/inputs.lua
Normal file
10
scripts/inputs.lua
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
function mouseOver(object)
|
||||
local mx, my = love.mouse.getPosition()
|
||||
local time = 0
|
||||
if mx > object.x and mx < object.x + object.width then
|
||||
if my > object.y and my < object.y + object.height then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
8
scripts/items.lua
Normal file
8
scripts/items.lua
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
function item.create(type, commands)
|
||||
local object = {}
|
||||
for i = 1, #commands do
|
||||
object[commands]
|
||||
i = i + 1
|
||||
end
|
||||
return object
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue