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

Member
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
Member
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 2,612 Aug 29, 2005 12:58 PM
Last Post: ThemsAllTook
  moving Mac OS X game to another OS X machine.... WhatMeWorry 15 5,589 Aug 19, 2005 09:19 AM
Last Post: AnotherJake
  Problem reading mouse button state Bossa Nova 3 3,192 Jul 23, 2003 12:09 PM
Last Post: Iceman
  State of OpenAL? KenD 16 6,971 Jul 11, 2003 05:35 PM
Last Post: Iceman