CStateSys

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply
Jookia
Posts: 170
Joined: Wed Nov 19, 2008 1:11 am

CStateSys

Post by Jookia »

This is a state machine that works well and doesn't afraid of anything.
Demo includes source code, an unfinished options dialog and sydney.mdl and Doxygen for CStateSys.h.

Comments are accepted.

DOWNLOAD
Last edited by Jookia on Thu Jun 25, 2009 12:49 pm, edited 3 times in total.
Brainsaw
Posts: 1242
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Post by Brainsaw »

Damnit ... I just wrote my state machine yesterday. ;)
Image
Dustbin::Games on the web: https://www.dustbin-online.de/
Jookia
Posts: 170
Joined: Wed Nov 19, 2008 1:11 am

Post by Jookia »

This allows parent->children relationships.
Brainsaw
Posts: 1242
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Post by Brainsaw »

Mine is pretty simple. It is a better version of the state machine I used in two of the demo applications of my IrrODE wrapper (IrrOdeCar, IrrOdeMarble), with a few more things in mind. I think I'll put it online here as soon as I got around to create something more than the switch-some-guis-test ;). But still ... it's very simple.
Image
Dustbin::Games on the web: https://www.dustbin-online.de/
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

I shared some state machine code a while back. You can find it here.

Code: Select all

if(event.GUIEvent.EventType == gui::EGET_BUTTON_CLICKED)
{
  if(name == "Quit")
    CQuitState* quitState = new CQuitState(manager, this);
  else if(name == "Broken Options")
    COptionsState* optionsState = new COptionsState(manager, this);
}
Who cleans up the memory allocated here? As far as I can tell, the states do not register themselves with the manager or set themselves as the current state, so they are probably leaks.
Ion Dune
Posts: 453
Joined: Mon Nov 12, 2007 8:29 pm
Location: California, USA
Contact:

Post by Ion Dune »

I think this state machine is a pretty cool guy. eh kills aleins

Always nice to see 4chan on irrlicht. But I think "works well" is a bit of a stretch, considering it crashes when you close the options or quit the application :lol:
Jookia
Posts: 170
Joined: Wed Nov 19, 2008 1:11 am

Post by Jookia »

Ion Dune wrote:I think this state machine is a pretty cool guy. eh kills aleins

Always nice to see 4chan on irrlicht. But I think "works well" is a bit of a stretch, considering it crashes when you close the options or quit the application :lol:
That was a bug that I fixed, I'm working on a more impressive tech demo. Just recompile.
vitek wrote:I shared some state machine code a while back. You can find it here.

Code: Select all

if(event.GUIEvent.EventType == gui::EGET_BUTTON_CLICKED)
{
  if(name == "Quit")
    CQuitState* quitState = new CQuitState(manager, this);
  else if(name == "Broken Options")
    COptionsState* optionsState = new COptionsState(manager, this);
}
Who cleans up the memory allocated here? As far as I can tell, the states do not register themselves with the manager or set themselves as the current state, so they are probably leaks.
The second argument is a parent. Once the parent is destroyed those states get destroyed.
Jookia
Posts: 170
Joined: Wed Nov 19, 2008 1:11 am

Post by Jookia »

There, I fixed my very bad example.
Post Reply