I'm having a hard time comprehending how the gamestate in LÖVE works; though I know for the most part that it involves creating a table or some sort. So far, I haven't seen any tutorial regarding this (and if there are, they tend to use the outdated version instead). Checking the source code of some LÖVE games is unfortunately of no help either, as they provide no inline documentation to easily help me figure out this problem.
Basically, for now I just want to know how to make a titlescreen gamestate consisting of a simple white background with three buttons (such as new game, options and exit). The selected button will have an arrow next to it, and it's controlled using the keyboard.
The logic of LÖVE's gamestate.
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: The logic of LÖVE's gamestate.
Love has no concept of gamestate (as far as I'm aware). You can use a drop-in solution like hump.gamestate or roll your own. It's mostly just a matter of forwarding callbacks (love.update/love.draw) and events to a different table of handlers for each gamestate, and storing some context (the actual "state") somewhere. You may also want a way to define things that happen when gamestates are loaded/unloaded, or manage a stack of active states.
Here's a rough outline:
Here's a rough outline:
Code: Select all
local game = {}
function game:setState (state)
self.state = state
end
function love.update (...)
return game.state.update(...)
end
function love.draw (...)
return game.state.draw(...)
end
local menuState = {
draw = drawMenu,
update = updateMenu
}
game:setState(menuState)
Re: The logic of LÖVE's gamestate.
If you were expecting functionality like this, there are probably other game creation tools that will suit you better. Game engines typically have these kinds of basic building -blocks built-in, which can speed up development. Personally, the main reason I'm using Löve is that it allows me to implement these kinds of things exactly the way I like.
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
Who is online
Users browsing this forum: Bing [Bot], NewbiePeta and 8 guests