Can someone explain the basics of gamestates for me please? I have read some people suggesting stuff like hump and other libraries, but i want to try and build it myself first.
I don't quite understand it, like how you "wrap" the, let's say game code, and separate it from the menu code?
Do you just take all the game code and throw it into a function, then run that function when the user presses "Start" on the menu? (which itself is a menu function?)
Thanks!
Gamestates
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Gamestates
It's not a single function.
Let's explain it like this:
A state is a collection of callbacks (so they all have an update, a draw, etc), and a state manager is then designed in a way that you can easily select an active state.
The active state is the one that receives the callbacks, so if you switch to the "menu" state, that will then react to update, draw, keypressed, mousepressed, etc.
Let's explain it like this:
A state is a collection of callbacks (so they all have an update, a draw, etc), and a state manager is then designed in a way that you can easily select an active state.
The active state is the one that receives the callbacks, so if you switch to the "menu" state, that will then react to update, draw, keypressed, mousepressed, etc.
Re: Gamestates
i just make a variable and use if's
gamestate = "menu"
if gamestate == "menu" do menu stuff
elseif gamestate == "playing" do playing stuff
but its a bit more of a pain in the butt due to love's callbacks, you have to have that in each appropriate section (like draw and update)
gamestate = "menu"
if gamestate == "menu" do menu stuff
elseif gamestate == "playing" do playing stuff
but its a bit more of a pain in the butt due to love's callbacks, you have to have that in each appropriate section (like draw and update)
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 5 guests