Game State Engine
  • Here's a little library I've been working on. It's based on the Guff Framework. I've wrapped a class around HGE that takes care of all the setup and initialization.

    Link:
    [list]Full Package:
    http://radishes.org/users/sharkgod999/GSE/downloads.htm
    Docs:
    http://radishes.org/users/sharkgod999/GSE/index.htm[/list:u]
    Feel free to leave any comments or change anything in the source. Just post it here if you do.

    Edit:
    Here's a little explanation on how to set this up. I've also added some info on state changes.
    http://radishes.org/users/sharkgod999/GSE/how_to_use_gse_with_hge.htm
  • Sorry to bump this thread. I just wanted to say I've added some documentation. I tried to add it earlier, but my power went out :cry: . So, I wrote it in html format. That way I could save it before I went to work. :) If you have any questions post them here. However, if you look at the headers it should help until I can get the complete docs finished and posted.
  • I haven't tried your framework yet, but I did notice a small problem with your "how to use" page. The link to the GSE download is broken. The links in your post are good, though.
  • There, I fixed the links in the "how to", and a little typo I found.
  • I've added a new version above, and updated the "How To". I'm currently working on some actual documentation. It's about 35% finished.
    [list]Library:
    http://radishes.org/users/sharkgod999/downloads/GSE_1.0.2.rar
    Source:
    http://radishes.org/users/sharkgod999/downloads/GSE_1.0.2_src.rar
    Docs:
    http://radishes.org/users/sharkgod999/GSE/index.htm[/list:u]
    Again, Let me know what you think. Hell, tell me if you even try it out, and have no opinion. :lol:
  • I've uploaded ver. 1.0.3 and am currently working on 1.1.0. The next release will feature:
    [list]-Fully automated game object management.
    -Superior collision detection and physics (Box2D).
    -Automatically restore BackBuffers texture on loss of focus[/list:u]
  • Sharkgod999Sharkgod999 August 2008
    I've gone ahead and updated to 1.0.4. I've included camera scrolling in the hgeApp class. You can download it at the link above.
  • CalabiCalabi August 2008
    Hi, I've downloaded it and am going to try it out. Thats if I can figure it out, as I'm a noobie programmer. It does seem pretty self explanatory though, so I shouldnt have much trouble.
  • cleerlinecleerline September 2008
    Looks good.

    My first game (http://lexiclix.com) used the giant switch statement approach. This was OK when I had 3 or 4 states. But when it got to having dozens of them, it became a nightmare. But by then it was too late.

    I was going to write a state manager myself for my next title, but this seems to fit the bill nicely.


    Thanks
  • xenusxenus October 2009
    I've got a problem by creating an app with this GameStateEngine..


    1>Kompilieren...
    1>main.cpp
    1>MenueState.cpp
    1>Code wird generiert...
    1>Manifest in Ressourcen wird kompiliert...
    1>Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
    1>Copyright (C) Microsoft Corporation. All rights reserved.
    1>Verknьpfen...
    1>GameStateEngine.lib(abstractApp.obj) : Es wurde ein mit /GL kompiliertes MSIL .netmodule oder module gefunden. Verknьpfung wird mit /LTCG erneut gestartet. Fьgen Sie /LTCG zur Linkbefehlszeile hinzu, um die Linkerleistung zu erhцhen.
    1>LINK : warning LNK4075: /INCREMENTAL wird aufgrund der Angabe von /LTCG ignoriert.
    1>LINK : warning LNK4098: Standardbibliothek "MSVCRT" steht in Konflikt mit anderen Bibliotheken; /NODEFAULTLIB:Bibliothek verwenden.
    1>Code wird generiert.
    1>Codegenerierung ist abgeschlossen.
    1>GameStateEngine.lib(MasterState.obj) : warning LNK4099: PDB "vc90.pdb" wurde nicht mit "E:\Spieleprogrammierung\GSE_1.0.4_src\GSE_1.0.4_src\Library\GameStateEngine.lib" oder an "E:\Spieleprogrammierung\HGE\Erstes\HGE_Programme\Debug\vc90.pdb" gefunden; Objekt wird verknьpft, als ob keine Debuginformationen vorhanden wдren.
    1>GameStateEngine.lib(abstractApp.obj) : warning LNK4099: PDB "vc90.pdb" wurde nicht mit "E:\Spieleprogrammierung\GSE_1.0.4_src\GSE_1.0.4_src\Library\GameStateEngine.lib" oder an "E:\Spieleprogrammierung\HGE\Erstes\HGE_Programme\Debug\vc90.pdb" gefunden; Objekt wird verknьpft, als ob keine Debuginformationen vorhanden wдren.
    1>GameStateEngine.lib(hgeApp.obj) : warning LNK4099: PDB "vc90.pdb" wurde nicht mit "E:\Spieleprogrammierung\GSE_1.0.4_src\GSE_1.0.4_src\Library\GameStateEngine.lib" oder an "E:\Spieleprogrammierung\HGE\Erstes\HGE_Programme\Debug\vc90.pdb" gefunden; Objekt wird verknьpft, als ob keine Debuginformationen vorhanden wдren.
    1>GameStateEngine.lib(StateRegistry.obj) : warning LNK4099: PDB "vc90.pdb" wurde nicht mit "E:\Spieleprogrammierung\GSE_1.0.4_src\GSE_1.0.4_src\Library\GameStateEngine.lib" oder an "E:\Spieleprogrammierung\HGE\Erstes\HGE_Programme\Debug\vc90.pdb" gefunden; Objekt wird verknьpft, als ob keine Debuginformationen vorhanden wдren.
    1>GameStateEngine.lib(StateGroup.obj) : warning LNK4099: PDB "vc90.pdb" wurde nicht mit "E:\Spieleprogrammierung\GSE_1.0.4_src\GSE_1.0.4_src\Library\GameStateEngine.lib" oder an "E:\Spieleprogrammierung\HGE\Erstes\HGE_Programme\Debug\vc90.pdb" gefunden; Objekt wird verknьpft, als ob keine Debuginformationen vorhanden wдren.
    1>GameStateEngine.lib(State.obj) : warning LNK4099: PDB "vc90.pdb" wurde nicht mit "E:\Spieleprogrammierung\GSE_1.0.4_src\GSE_1.0.4_src\Library\GameStateEngine.lib" oder an "E:\Spieleprogrammierung\HGE\Erstes\HGE_Programme\Debug\vc90.pdb" gefunden; Objekt wird verknьpft, als ob keine Debuginformationen vorhanden wдren.
    1>Das Manifest wird eingebettet...
    1>Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
    1>Copyright (C) Microsoft Corporation. All rights reserved.
    1>GameStateEngine.lib(abstractApp.obj) : Es wurde ein mit /GL kompiliertes MSIL .netmodule oder module gefunden. Verknьpfung wird mit /LTCG erneut gestartet. Fьgen Sie /LTCG zur Linkbefehlszeile hinzu, um die Linkerleistung zu erhцhen.
    1>LINK : warning LNK4075: /INCREMENTAL wird aufgrund der Angabe von /LTCG ignoriert.
    1>LINK : warning LNK4098: Standardbibliothek "MSVCRT" steht in Konflikt mit anderen Bibliotheken; /NODEFAULTLIB:Bibliothek verwenden.
    1>Code wird generiert.
    1>Codegenerierung ist abgeschlossen.
    1>GameStateEngine.lib(abstractApp.obj) : warning LNK4099: PDB "vc90.pdb" wurde nicht mit "E:\Spieleprogrammierung\GSE_1.0.4_src\GSE_1.0.4_src\Library\GameStateEngine.lib" oder an "e:\Spieleprogrammierung\HGE\Erstes\HGE_Programme\Debug\vc90.pdb" gefunden; Objekt wird verknьpft, als ob keine Debuginformationen vorhanden wдren.
    1>GameStateEngine.lib(hgeApp.obj) : warning LNK4099: PDB "vc90.pdb" wurde nicht mit "E:\Spieleprogrammierung\GSE_1.0.4_src\GSE_1.0.4_src\Library\GameStateEngine.lib" oder an "e:\Spieleprogrammierung\HGE\Erstes\HGE_Programme\Debug\vc90.pdb" gefunden; Objekt wird verknьpft, als ob keine Debuginformationen vorhanden wдren.
    1>GameStateEngine.lib(StateRegistry.obj) : warning LNK4099: PDB "vc90.pdb" wurde nicht mit "E:\Spieleprogrammierung\GSE_1.0.4_src\GSE_1.0.4_src\Library\GameStateEngine.lib" oder an "e:\Spieleprogrammierung\HGE\Erstes\HGE_Programme\Debug\vc90.pdb" gefunden; Objekt wird verknьpft, als ob keine Debuginformationen vorhanden wдren.
    1>GameStateEngine.lib(StateGroup.obj) : warning LNK4099: PDB "vc90.pdb" wurde nicht mit "E:\Spieleprogrammierung\GSE_1.0.4_src\GSE_1.0.4_src\Library\GameStateEngine.lib" oder an "e:\Spieleprogrammierung\HGE\Erstes\HGE_Programme\Debug\vc90.pdb" gefunden; Objekt wird verknьpft, als ob keine Debuginformationen vorhanden wдren.
    1>GameStateEngine.lib(State.obj) : warning LNK4099: PDB "vc90.pdb" wurde nicht mit "E:\Spieleprogrammierung\GSE_1.0.4_src\GSE_1.0.4_src\Library\GameStateEngine.lib" oder an "e:\Spieleprogrammierung\HGE\Erstes\HGE_Programme\Debug\vc90.pdb" gefunden; Objekt wird verknьpft, als ob keine Debuginformationen vorhanden wдren.
    1>GameStateEngine.lib(MasterState.obj) : warning LNK4099: PDB "vc90.pdb" wurde nicht mit "E:\Spieleprogrammierung\GSE_1.0.4_src\GSE_1.0.4_src\Library\GameStateEngine.lib" oder an "e:\Spieleprogrammierung\HGE\Erstes\HGE_Programme\Debug\vc90.pdb" gefunden; Objekt wird verknьpft, als ob keine Debuginformationen vorhanden wдren.



    I know it's german but you perhaps know that linker errors.
    When the app is starting it stops at the constructor of the customState i think cause m_hge can not initialize.

    I use Windows 7 and Visual Studio 2008 C++ , i linked the include and lib folders correctly ..

    Does someone can help me ?
  • Sharkgod999Sharkgod999 October 2009
    It appears - according to google translations - the warnings you are getting are simply saying there will be no debug info available. I've never had that issue. Probably because I always include the source in the workspace and make it a dependency of my game project. Try that if you want debug info. Same thing I have to do with Box2d and many other libs to get the debug info.

    Sorry I couldn't give you better help, but I've been to busy with my day job.
  • softmaniacsoftmaniac November 2009
    Sharkgod999 can you share example?
  • Sharkgod999Sharkgod999 December 2009
    If you're using MS Studio, just add the existing project to the solution, and set the dependencies and directories accordingly. :) I can't really tell you how this might work with any other compilers though. :(
  • softmaniacsoftmaniac December 2009
    I need example how to change states. :D
  • Sharkgod999Sharkgod999 December 2009
    From the tutorial above:

    Changing States

    There are two ways to change states: temporary and permanent. A temporary change will remember the state before the call. In other words the caller is not removed from the hosts stack and the next state is placed on top. Temporary changes are made using the StateGroup::pushState and StateGroup::popState members. A permanent change does not remember the former states. The host clears the stack and pushes the new state on top. Permanent changes are made using the StateGroup::changeState member.

    1
    2
    3
    4
    5
    6
     //  Temporary State Change
    pushState("newState"); // Pushes new state onto stack
    popState(); // Returns to previous state
     
    // Permanent State Change
    changeState("newState") // Flushes all previous states and pushes the new state on to the stack

    All you need to do is make the appropriate call and pass it the ID of the state you want to switch to.
  • LisergishnuLisergishnu August 2010
    I've been trying to use this engine, looks quite useful. The problem is that i get an exception in runtime before it starts the hge engine, though I just copy-pasted your examples to give it a try (since i'm using Code::Blocks with GCC).

    I've tried to trace the error and what I have is that the exception occurs in
    1
    2
    3
    4
    5
    6
    MasterState * MasterState::getInstance()
    {
    static auto_ptr<MasterState> p(new MasterState);
     
    return p.get();
    }


    the auto_ptr seems to throw the exception. Since i've never used auto_ptr some advice would be very useful :o
  • kvakvskvakvs August 2010

    I've been trying to use this engine, looks quite useful. The problem is that i get an exception in runtime before it starts the hge engine, though I just copy-pasted your examples to give it a try (since i'm using Code::Blocks with GCC).

    I've tried to trace the error and what I have is that the exception occurs in

    1
    2
    3
    4
    5
    6
    MasterState * MasterState::getInstance()
    {
    static auto_ptr<MasterState> p(new MasterState);
     
    return p.get();
    }


    the auto_ptr seems to throw the exception. Since i've never used auto_ptr some advice would be very useful :o

    Autoptr is simple like an iron nail.
    To make autoptr throw something, Masterstate class ctor must throw something. Check if you're creating it correctly, at the correct time and correct everything.
  • LisergishnuLisergishnu August 2010
    I've been the last hours trying to trace down the exception, Masterclass ctor is really simple
    1
    2
    3
    MasterState::MasterState()
    : StateGroup(MASTER_STATE_ID, "")
    {}


    Which points to another class which isn't in the stack at the moment of the exception. What I really don't understand is that the engine comes in a static library fashion, and given I have followed the how-to instructions copy-pasting, I just can't get it working. My money is on my compiler (GCC) but I have tried rebuilding the whole library, and also including the source to my proyect so it gets build into compile-time, with no results. Is it normal that the dialog error says "Microsoft C++ Library" since I'm using GCC?
  • kvakvskvakvs August 2010

    Is it normal that the dialog error says "Microsoft C++ Library" since I'm using GCC?


    I guess you are using gcc under cygwin, and it links windows EXE file against Microsoft Windows SDK libraries, which are free to download on MS website. Hence why there is "Microsoft C++".

    Get Microsoft Studio and compiler, and see the difference. Express studio is free to use for anyone.
    http://www.microsoft.com/express/

    Anyway, I can't suggest anything specific regarding your problem, because my use of state machines is minimal (only for fullscreen crossfade effect when changing 2D game scenes) and i did not ever use this library.
  • 1
    2
    3
    4
    5
    6
    7
    8
    /*==================================================
    / menuState::~menuState
    / Destructor : public
    / DO NOT delete ANY HGE specific members here
    /=================================================*/

    menuState::~menuState(void)
    {
    }

    Then where I can clear memory?
    For example I created:
    1
    gui=new hgeGUI();
  • Sorry for the delay. In case you didn't catch it already: delete hge members in the menuState::Shutdown() func. There seems to be a typo in the docs. Sorry again for my inactivity.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership

In this Discussion

Who's Online (2)