[C++] How do you implement a state chart or state machine?

Posts: 249
Joined: 2008.10
Post: #1
Hi friends!

How do you implement a state chart or state machine in C++? I mean, which technique do you use? can you write a small example? How do you store transitions? Or any useful link.
I use a switch with a list of states, but I don't use transitions, so I guess I doing it bad.
Note: I would prefer in C++ without any library like Boost.
Is there any program opr IDE to draw state charts and then create its code in C++? Something like assitant.

Thanks a lot for your time, this is a very important part in every game.
Quote this message in a reply
Posts: 116
Joined: 2002.04
Post: #2
I don't think there's any one formula for a state machine.

If the state change is immediate, then there's no need for a transition.

You do obviously want to be careful to guard against getting stuck in a state loop, or stuck in a single state. However, the details of how that can happen and how to avoid it would be totally dependent on what you're doing.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  State Tables and Event Handling geolycosa 1 3,279 Aug 29, 2005 12:58 PM
Last Post: ThemsAllTook
  moving Mac OS X game to another OS X machine.... WhatMeWorry 15 7,177 Aug 19, 2005 09:19 AM
Last Post: AnotherJake
  Problem reading mouse button state Bossa Nova 3 4,278 Jul 23, 2003 12:09 PM
Last Post: Iceman
  State of OpenAL? KenD 16 9,420 Jul 11, 2003 05:35 PM
Last Post: Iceman