status = "startup"
or
status = "menu"
or
status = "game"
Each of these status will point to a file in the functions folder like so
require("functions/menu")
if (status == "menu") then
menu()
end
and this function will create everything needed within that part of the game.
I'm having a little trouble understanding why there is a separate love.update() and love.draw(), when both are called every tick. I can understand this for simplicity in very simple games, but for complex games it would seem to just make things 2000 time more complex than it needs to be if I have to split up calculations and draw functions.
Here is my main.lua
Code: Select all
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
function love.load()
require("functions/file")
require("functions/menu")
status = "menu"
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
function love.update(dt)
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
function love.draw()
if (status == "menu") then
menu()
end
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Code: Select all
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
menu_check = false
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
function menu()
if (menu_check == false) then
background = love.graphics.newImage("resources/menu/bg.jpg")
menu_check = true
else
menu_main()
end
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
function menu_main()
deltatime = love.timer.getDelta()
love.graphics.print(deltatime,10,10)
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
So is it nessacery for me to even use the love.update() function at all? I can set the delta time easily with love.timer.getDelta() function so I see no need to put any of my code within love.update(). Again, I see the need for beginners to use it but the more complex the game gets, it seems this separation becomes unnecessary.
So can someone please enlighten me on what this is all about and if I'm looking at this the right way?
Also, I want to be able to set variables only once, not every tick, which is what the if menu_check function is for, but is there a more efficient way to do this?
Thanks!