2D Game Dev – Part 13.2 – Better Game State Implementation

This post is a portion of Part 13 in my on going series about 2D Game Development using the Allegro 5 library. These posts are in course order. You can see all of the posts in this course by clicking the “2D Game Development” button at the top of this site.

 


In this video we focus on improving out game state system. Using a method ‘ChangeState()’ we are able to add robustness. The video covers the use of pre and post state change commands. That is to say, we can execute code when we leave a state and when we enter a state to help improve the overall flow of our games.

Full source can be found here.

Posted in 2D Game Dev, Allegro, C++, Code, Game Dev, Part 13, Tutorial
3 Comments » for 2D Game Dev – Part 13.2 – Better Game State Implementation
  1. Jesus Christ says:

    Why not using switch?

  2. Cody says:

    Thanks for that info on removing the console window, I get so annoyed with that thing, it becomes an eyesore when that’s all you’ve ever coded on pre-allegro.

  3. Mario says:

    I use Ubuntu 11.10 to compile this, and if I use give me the the next error:
    /tmp/ccU6EFl0.o: In function `__static_initialization_and_destruction_0(int, int)’:
    main.cpp:(.text+0×656): undefined reference to `std::ios_base::Init::Init()’
    main.cpp:(.text+0x65b): undefined reference to `std::ios_base::Init::~Init()’

    so, because in ubuntu the console is open already(compile with commands), I use the header and for the outputs a simple printf(“Entering MENU state”) and it works :)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Error: Twitter did not respond. Please wait a few minutes and refresh this page.