Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: About game states  (Read 2694 times)

0 Members and 1 Guest are viewing this topic.


  • Newbie
  • *
  • Posts: 14
    • View Profile
About game states
« on: April 13, 2021, 09:56:07 pm »
I am trying to make a small game(new to sfml) and I heard about theese game states, but I can not find any sites or  tutorials on what are them or how to use them. Can anyone link me to some good sites or briefly explain what are those?


  • Sr. Member
  • ****
  • Posts: 290
  • C++/C# game dev teacher.
    • View Profile
Re: About game states
« Reply #1 on: April 14, 2021, 02:40:06 am »
Usually I'd assume game state is using something like a Finite State Machime (FSM).

For a game you could have states like:
  • Title Screen
  • Main menu
  • Options menu
  • Get Ready (show a message for a second or so)
  • Playing
  • Game Over (show a game over message for a few seconds)

The most simplistic way to handle that would be an enum for each state and a variable to hold the current state.
enum GameState

GameState currentState;

Then during the game you'd run different logic and rendering code depending on the value in currentState.
A more advanced state system could use classes, stacks with history (to undo out of a state), etc.

FSMs can also be used deeper in the game, such as for AI, there could be a heap of different ones in one game.


  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: About game states
« Reply #2 on: April 16, 2021, 08:15:53 am »
@AdrianHey: please follow the advice I gave you in my last answer.

It's not nice to ask a low-effort question without research, let people spend a big amount of time answering and then not even get back to them.

The only question that you replied to was this one, and interestingly it's exactly the one where you spent more time asking the question.
All the others are two-sentence questions and remain unanswered:

If you continue like this, soon people will stop helping you altogether.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: