Advanced Keyboard Handling

Hey all!

I am working on a new game that requires me to check for special moves.
Here is what I have currently:

struct:
key name
seconds pressed
next struct

Now if someone presses up down left or right, it will create a new
struct
and add it to the linked list.

I have it right now adding to the link list and printing it out. The
problem I am having trouble with is with finding if the list contains a
special move or not… I also have moves that will have two second hold
downs … kind of like street fighter two and guiles sonic boom and
flash
kick… I probably also need to clear the list every once in a while
right?

Am I even on the right track? does someone have a better method? thanks!

Interesting… I’ve never heard of this before… Is there a place on the
net that you know of that will give me more information?On Sun, 12 Dec 1999, Prasanth Kumar wrote:

I think what you need to do is have some kind of state machine to handle the
special moves. The character starts out at some neutral state. Based on a
key press input and the current state, the state machine jumps to another
state. When a proper sequence of state jumps are made, a special move is
executed. If an improper sequence is made along any point or there is
hesitation, it jumps back to neutral state. If a move requires hold downs,
it might be handled using intermediate states.

All this can be implemented using an array of arrays. Each element of the
outer array would be a specific state while inside each of this would be a
list of new states based on the keyboard input.

----- Original Message -----
From: “Ryan Wahle” <@Ryan_Wahle>
Newsgroups: loki.open-source.sdl
To:
Sent: Sunday, December 12, 1999 6:11 AM
Subject: [SDL] Advanced Keyboard Handling

Hey all!

I am working on a new game that requires me to check for special moves.
Here is what I have currently:

struct:
key name
seconds pressed
next struct

Now if someone presses up down left or right, it will create a new
struct
and add it to the linked list.

I have it right now adding to the link list and printing it out. The
problem I am having trouble with is with finding if the list contains a
special move or not… I also have moves that will have two second hold
downs … kind of like street fighter two and guiles sonic boom and
flash
kick… I probably also need to clear the list every once in a while
right?

Am I even on the right track? does someone have a better method? thanks!

This seems good, but it seems like it’s only good after I find out if the
special move needs to be performed… Like

if (special move = true)
state = special move

But how do I get the special move… After reading a few documents, and
emails from you two, I’m come up with something like this.

Generic code:

char x[100];

x = GetKeyboardInput();

if ( x[0] = specialmove[0] )
if ( x[1] = specialmove[1] )
if ( x[2] = specialmove[2] )
// End of specialmove sequence
PerformSpecialMove();

// Not a special move so just interpret as regular moves

if ( x[0] = forward or back or up or down )
move accordingly ();

if ( x[1] = … )
move accordingly ();

All the way until there is no more x and then start the whole process
over… Is this on the right track?On Sun, 12 Dec 1999, Austin Henry wrote:

  • Ryan Wahle arranged a host of electrons thusly: -

Ryan,
The term you want to search on is “finite state machine.” there
should be some good information out there on the web, mostly in
computer science web pages.

Basically, there are certain states that the “machine” can be in.
Input to the machine can trigger a transition from one state to
another. So if you had a collection of states whose transitions were
things like “A key pressed” and “C key held down for 2 seconds” you
would get an idea at least of where to start designing your state
machine for your specaal moves. You’ll probably only need one machine
to handle all of the specials (perhaps one per character).

State machines are a very useful construct for programming lots of
things. For instance I used a FSM to model the behaviour of a slightly
dull cat, and the program a robot to act like that cat.

Hmm. If I describe more, I’ll be going on for pages :slight_smile: We spent
several weeks on state machine related issues in one of my 3rd year
computer science classes.

If you want more info, mail me & I’ll try, but there should be some
good info on the web

http://www.belgarath.demon.co.uk/java/fsme.html looks like it might be
a good place to start (but I don’t have java turned on, so I can’t
really tell).

peace,
ah

Interesting… I’ve never heard of this before… Is there a place on the
net that you know of that will give me more information?

On Sun, 12 Dec 1999, Prasanth Kumar wrote:

I think what you need to do is have some kind of state machine to handle the
special moves. The character starts out at some neutral state. Based on a
key press input and the current state, the state machine jumps to another
state. When a proper sequence of state jumps are made, a special move is
executed. If an improper sequence is made along any point or there is
hesitation, it jumps back to neutral state. If a move requires hold downs,
it might be handled using intermediate states.

All this can be implemented using an array of arrays. Each element of the
outer array would be a specific state while inside each of this would be a
list of new states based on the keyboard input.


Practice random acts of intelligence, senseless self control, and suffer
not from recto-cranial inversion.
-> latest fortune cookie to grab my attention <-
These hands!! I can’t get them off my wrists!!! OH GOD!!!

I think what you need to do is have some kind of state machine to handle the
special moves. The character starts out at some neutral state. Based on a
key press input and the current state, the state machine jumps to another
state. When a proper sequence of state jumps are made, a special move is
executed. If an improper sequence is made along any point or there is
hesitation, it jumps back to neutral state. If a move requires hold downs,
it might be handled using intermediate states.

All this can be implemented using an array of arrays. Each element of the
outer array would be a specific state while inside each of this would be a
list of new states based on the keyboard input.> ----- Original Message -----

From: wahle@addell.com (Ryan Wahle)
Newsgroups: loki.open-source.sdl
To:
Sent: Sunday, December 12, 1999 6:11 AM
Subject: [SDL] Advanced Keyboard Handling

Hey all!

I am working on a new game that requires me to check for special moves.
Here is what I have currently:

struct:
key name
seconds pressed
next struct

Now if someone presses up down left or right, it will create a new
struct
and add it to the linked list.

I have it right now adding to the link list and printing it out. The
problem I am having trouble with is with finding if the list contains a
special move or not… I also have moves that will have two second hold
downs … kind of like street fighter two and guiles sonic boom and
flash
kick… I probably also need to clear the list every once in a while
right?

Am I even on the right track? does someone have a better method? thanks!

I don’t know of any website at this moment to cover it. I do know of some
books which
cover this, typically under the section on machine intelligence of computer
controlled characters.
The particular one that I have is “Black art of 3d game programming” by
Andre LaMothe.> ----- Original Message -----

From: wahle@addell.com (Ryan Wahle)
To:
Sent: Sunday, December 12, 1999 11:07 AM
Subject: Re: [SDL] Advanced Keyboard Handling

Interesting… I’ve never heard of this before… Is there a place on the
net that you know of that will give me more information?

On Sun, 12 Dec 1999, Prasanth Kumar wrote:

I think what you need to do is have some kind of state machine to handle
the

special moves. The character starts out at some neutral state. Based on
a

key press input and the current state, the state machine jumps to
another

state. When a proper sequence of state jumps are made, a special move is
executed. If an improper sequence is made along any point or there is
hesitation, it jumps back to neutral state. If a move requires hold
downs,

it might be handled using intermediate states.

All this can be implemented using an array of arrays. Each element of
the

outer array would be a specific state while inside each of this would be
a

list of new states based on the keyboard input.

----- Original Message -----
From: “Ryan Wahle”
Newsgroups: loki.open-source.sdl
To:
Sent: Sunday, December 12, 1999 6:11 AM
Subject: [SDL] Advanced Keyboard Handling

Hey all!

I am working on a new game that requires me to check for special
moves.

Here is what I have currently:

struct:
key name
seconds pressed
next struct

Now if someone presses up down left or right, it will create a new
struct
and add it to the linked list.

I have it right now adding to the link list and printing it out. The
problem I am having trouble with is with finding if the list contains
a

special move or not… I also have moves that will have two second hold
downs … kind of like street fighter two and guiles sonic boom and
flash
kick… I probably also need to clear the list every once in a while
right?

Am I even on the right track? does someone have a better method?
thanks!

  • Ryan Wahle arranged a host of electrons thusly: -

Ryan,
The term you want to search on is “finite state machine.” there
should be some good information out there on the web, mostly in
computer science web pages.

Basically, there are certain states that the “machine” can be in.
Input to the machine can trigger a transition from one state to
another. So if you had a collection of states whose transitions were
things like “A key pressed” and “C key held down for 2 seconds” you
would get an idea at least of where to start designing your state
machine for your specaal moves. You’ll probably only need one machine
to handle all of the specials (perhaps one per character).

State machines are a very useful construct for programming lots of
things. For instance I used a FSM to model the behaviour of a slightly
dull cat, and the program a robot to act like that cat.

Hmm. If I describe more, I’ll be going on for pages :slight_smile: We spent
several weeks on state machine related issues in one of my 3rd year
computer science classes.

If you want more info, mail me & I’ll try, but there should be some
good info on the web

http://www.belgarath.demon.co.uk/java/fsme.html looks like it might be
a good place to start (but I don’t have java turned on, so I can’t
really tell).

peace,
ah> Interesting… I’ve never heard of this before… Is there a place on the

net that you know of that will give me more information?

On Sun, 12 Dec 1999, Prasanth Kumar wrote:

I think what you need to do is have some kind of state machine to handle the
special moves. The character starts out at some neutral state. Based on a
key press input and the current state, the state machine jumps to another
state. When a proper sequence of state jumps are made, a special move is
executed. If an improper sequence is made along any point or there is
hesitation, it jumps back to neutral state. If a move requires hold downs,
it might be handled using intermediate states.

All this can be implemented using an array of arrays. Each element of the
outer array would be a specific state while inside each of this would be a
list of new states based on the keyboard input.


Practice random acts of intelligence, senseless self control, and suffer
not from recto-cranial inversion.
-> latest fortune cookie to grab my attention <-
These hands!! I can’t get them off my wrists!!! OH GOD!!!

I would do something like:

char x;

movestate=0;
x=GetKeyboardInput();
movestate=NextState(movestate,x);
if (movestate<0) { /* a movestate lower than 0 is
special /
DoSpecialMove(movestate);
movestate=0; /
go back to neutral state */
} else
DoStandardMove(x);

The NextState function takes the current state and a keyboard key to
determine the next state.
A movestate of 0 is some neutral state. A movestate greater than 0 is some
intermediate state
and a movestate below 0 signifies that a special move. NextState basically
looks up a static array
of state transitions.

Thus for guile’s sonicboom move, we might have something like:

NEUTRALSTATE->STATE1->STATE2->SONICBOOM

The 2 intermediate states are each consecutively triggered when the joystick
is moved left, then center, then right. If the player deviates from that
pattern, the sonic boom is never done.> ----- Original Message -----

From: wahle@addell.com (Ryan Wahle)
To:
Sent: Sunday, December 12, 1999 3:07 PM
Subject: Re: [SDL] Advanced Keyboard Handling

This seems good, but it seems like it’s only good after I find out if the
special move needs to be performed… Like

if (special move = true)
state = special move

But how do I get the special move… After reading a few documents, and
emails from you two, I’m come up with something like this.

Generic code:

char x[100];

x = GetKeyboardInput();

if ( x[0] = specialmove[0] )
if ( x[1] = specialmove[1] )
if ( x[2] = specialmove[2] )
// End of specialmove sequence
PerformSpecialMove();

// Not a special move so just interpret as regular moves

if ( x[0] = forward or back or up or down )
move accordingly ();

if ( x[1] = … )
move accordingly ();

All the way until there is no more x and then start the whole process
over… Is this on the right track?

(comments inline)

  • Ryan Wahle arranged a host of electrons thusly: -

This seems good, but it seems like it’s only good after I find out if the
special move needs to be performed… Like

well, if you’re going to adopt a state machine model for input, you’d be
best to use it for more than just special moves, I think.

if (special move = true)
state = special move

But how do I get the special move… After reading a few documents, and
emails from you two, I’m come up with something like this.

Generic code:

char x[100];

x = GetKeyboardInput();

if ( x[0] = specialmove[0] )
if ( x[1] = specialmove[1] )
if ( x[2] = specialmove[2] )
// End of specialmove sequence
PerformSpecialMove();

// Not a special move so just interpret as regular moves

if ( x[0] = forward or back or up or down )
move accordingly ();

if ( x[1] = … )
move accordingly ();

Hmm, I’d be more inclined to go with something like this:
( let’s assume that we have two special moves whose sequences are aBa
and aBc respectively )

int state;

key = GetKeyboardInput();

switch (state)
case START_STATE:
if (key == ‘a’)
state = SPEC_STATE1;
else
move_accordingly();
case SPEC_STATE1:
if (key == ‘B’)
state = SPEC_STATE2;
else
state = START_STATE;
case SPEC_STATE2:
if (key == ‘a’)
do_special1();
else if (key == ‘c’)
do_special2();

state = START_STATE;  

hctiws

Notice how there are only three states? That kind of thing is one of
the reasons that state machines are cool. Look on the web (or in a comp
sci text) for material on finding regular expressions with DFAs
(Deterministic Finite Automata), this is essentially what we’re doing.
There are processes you can follow to get minimal state machines (which
means less tedious programming!) fairly easily. Understanding what
you’re doing is a bit harder (but worth it imho). I’ll shut up about
this now :slight_smile:

But the way it works is that the machine is in a certain state and that
at any given state, it takes input and makes a transition to another
state (or to itself, acutally) based on that input. while you’re
performing the transition, you may choose to cause some side effects
(this is what makes the model useful) such as making the character move,
or performing a special move, if the right sequence has been pressed.

There are probably faster/more efficent ways to code these things, but I
think this structure makes it very clear what’s going on.

Does this make sense, or have i bombarded you with too much information?
If I haven’t explained well enough, ask away, this is one my favourite
designs, though I haven’t used it terribly often.

If anyone has a better way to code these, reply & feel free to tell me
that my way sucks :slight_smile:

peace,
ah> On Sun, 12 Dec 1999, Austin Henry wrote:

  • Ryan Wahle arranged a host of electrons thusly: -

Ryan,
The term you want to search on is “finite state machine.” there
should be some good information out there on the web, mostly in
computer science web pages.

Basically, there are certain states that the “machine” can be in.
Input to the machine can trigger a transition from one state to
another. So if you had a collection of states whose transitions were
things like “A key pressed” and “C key held down for 2 seconds” you
would get an idea at least of where to start designing your state
machine for your specaal moves. You’ll probably only need one machine
to handle all of the specials (perhaps one per character).

State machines are a very useful construct for programming lots of
things. For instance I used a FSM to model the behaviour of a slightly
dull cat, and the program a robot to act like that cat.

Hmm. If I describe more, I’ll be going on for pages :slight_smile: We spent
several weeks on state machine related issues in one of my 3rd year
computer science classes.

If you want more info, mail me & I’ll try, but there should be some
good info on the web

http://www.belgarath.demon.co.uk/java/fsme.html looks like it might be
a good place to start (but I don’t have java turned on, so I can’t
really tell).

peace,
ah

Interesting… I’ve never heard of this before… Is there a place on the
net that you know of that will give me more information?

On Sun, 12 Dec 1999, Prasanth Kumar wrote:

I think what you need to do is have some kind of state machine to handle the
special moves. The character starts out at some neutral state. Based on a
key press input and the current state, the state machine jumps to another
state. When a proper sequence of state jumps are made, a special move is
executed. If an improper sequence is made along any point or there is
hesitation, it jumps back to neutral state. If a move requires hold downs,
it might be handled using intermediate states.

All this can be implemented using an array of arrays. Each element of the
outer array would be a specific state while inside each of this would be a
list of new states based on the keyboard input.


Practice random acts of intelligence, senseless self control, and suffer
not from recto-cranial inversion.
-> latest fortune cookie to grab my attention <-
These hands!! I can’t get them off my wrists!!! OH GOD!!!


Practice random acts of intelligence, senseless self control, and suffer
not from recto-cranial inversion.
-> latest fortune cookie to grab my attention <-
These hands!! I can’t get them off my wrists!!! OH GOD!!!

I like this idea alot. . . So basically it would be a huge switch
statement correct? Tell me if this is correct:

Special Moves=============
DOWN LEFT
LEFT RIGHT
LEFT DOWN LEFT
DOWN UP DOWN

int state;

key = GetKeyboardInput();

switch (state)
case START_STATE:
if (key = DOWN)
state = DOWN;
if (key = LEFT)
state = LEFT;

	else
		MovePlayer();
case DOWN:
	if (key = LEFT)
		special move();
	if (key = UP)
		state_down = UP;

	switch (state_down)
		case UP:
			if (key = DOWN)
				special move();

and the same for the other moves also… and i would need to set the state
to START_STATE again if no special move has been found…

Is this correct?

On Sun, 12 Dec 1999, Austin Henry wrote:

Hmm, I’d be more inclined to go with something like this:
( let’s assume that we have two special moves whose sequences are aBa
and aBc respectively )

int state;

key = GetKeyboardInput();

switch (state)
case START_STATE:
if (key == ‘a’)
state = SPEC_STATE1;
else
move_accordingly();
case SPEC_STATE1:
if (key == ‘B’)
state = SPEC_STATE2;
else
state = START_STATE;
case SPEC_STATE2:
if (key == ‘a’)
do_special1();
else if (key == ‘c’)
do_special2();

state = START_STATE;  

hctiws

Notice how there are only three states? That kind of thing is one of
the reasons that state machines are cool. Look on the web (or in a comp
sci text) for material on finding regular expressions with DFAs
(Deterministic Finite Automata), this is essentially what we’re doing.
There are processes you can follow to get minimal state machines (which
means less tedious programming!) fairly easily. Understanding what
you’re doing is a bit harder (but worth it imho). I’ll shut up about
this now :slight_smile:

But the way it works is that the machine is in a certain state and that
at any given state, it takes input and makes a transition to another
state (or to itself, acutally) based on that input. while you’re
performing the transition, you may choose to cause some side effects
(this is what makes the model useful) such as making the character move,
or performing a special move, if the right sequence has been pressed.

There are probably faster/more efficent ways to code these things, but I
think this structure makes it very clear what’s going on.

Does this make sense, or have i bombarded you with too much information?
If I haven’t explained well enough, ask away, this is one my favourite
designs, though I haven’t used it terribly often.

If anyone has a better way to code these, reply & feel free to tell me
that my way sucks :slight_smile:

peace,
ah

Ryan Wahle wrote:

I like this idea alot. . . So basically it would be a huge switch
statement correct? Tell me if this is correct:

Special Moves

DOWN LEFT
LEFT RIGHT
LEFT DOWN LEFT
DOWN UP DOWN

int state;

key = GetKeyboardInput();

switch (state)
case START_STATE:
if (key = DOWN)
state = DOWN;
if (key = LEFT)
state = LEFT;

            else
                    MovePlayer();
    case DOWN:
            if (key = LEFT)
                    special move();
            if (key = UP)
                    state_down = UP;

            switch (state_down)
                    case UP:
                            if (key = DOWN)
                                    special move();

and the same for the other moves also… and i would need to set the state
to START_STATE again if no special move has been found…

Is this correct?

In a sense, you got it right that it is a “huge switch statement”, but
your implementation doesn’t have the right smell… Specifically, the
second switch inside the first one has nothing to do there.

This is a simple table.

For example, say you have UP, DOWN, LEFT and RIGHT, as well as a SPIN
special move which is activated by doing LEFT RIGHT LEFT successively:

State 1: initial state
if key == UP -> 2
if key == DOWN -> 3
if key == LEFT -> 6
if key == RIGHT -> 5
else -> 1

State 2: up
do the “up” stuff
-> 1

State 3: down
do the “down” stuff
-> 1

State 4: left
do the “left” stuff
-> 1

State 5: right
do the “right” stuff
-> 1

State 6: move1-left1
if key == RIGHT -> 7
-> 4

State 7: move1-right
if key == LEFT -> 9
-> 5

State 9: move1-left2
do the “spin” stuff
-> 1

See how it works? So you have a “state” variable that say where you’re
going next time you get into the switch. Note that this is very useful
for simple AI with multiple “bots”, as you can easily go thru that
switch once for each bot, with each of them having their own state
variable. For example:

int monster1_fsm(int state) {
switch(state) {
case 1:
bla bla;
return next_state; /* you probably have more than one of these */
case 2:
bla bla;
return next_state;
}
}

Then, in your main loop:

int i;

for(i = 0; i < num_monster1; i++)
monster1[i] = monster1_fsm(monster1[i]);

This will “run” the monster 1 AI for all the monster 1 active in the
game.

Many people consider games as graphics, tiles, sprites and so on, but I
tend to see two main things in games: the input, the state machines and
the main loop which ties them together.

One last hint: it helps a lot to have some kind of event system with
state machines, as you won’t have a single “if” statement, but plenty of
them scattered over multiple state machines. Consider time to be an
event. Some basics:

enum EventType {
EV_KEY,
EV_MOUSE,
EV_JOYSTICK,
EV_NETWORK,
EV_TIME
};

struct Event {
enum EventType type;
struct Event* next;
};

struct Event_Key {
/* those need to be the same as “struct Event” /
enum EventType type;
struct Event
next;
/* key event specific info here */

};

Then you need a queue of events. The main loop will wait for some input
to happen and sends the according event (or a time event if too much
time without input passed by, use poll() or select(), with their timeout
parameter for this). When an event happen, you go through the state
machines, then go back to wait for the next event.

A good place to do the redrawing is after the state machines, before
looping to the event wait, as you can have the state machine change a
variable when something needs to be redrawed, and do it right at the
end. If nothing needs to be drawn, just skip the drawing part.–
Pierre Phaneuf
Ludus Design, http://ludusdesign.com/
“First they ignore you. Then they laugh at you.
Then they fight you. Then you win.” – Gandhi

  • Ryan Wahle arranged a host of electrons thusly: -

I like this idea alot. . . So basically it would be a huge switch
statement correct? Tell me if this is correct:

I’ll change your code inline & then explain why I changed it.

Special Moves

DOWN LEFT
LEFT RIGHT
LEFT DOWN LEFT
DOWN UP DOWN

int state;

key = GetKeyboardInput();

switch (state)
case START_STATE:
if (key = DOWN)
state = DOWN;
if (key = LEFT)
state = LEFT;

  else
  	MovePlayer();

case DOWN:
if (key = LEFT)
special move();
if (key = UP)
state = DOWN_UP;

case DOWN_UP:
	if (key = DOWN)
			special move();

and the same for the other moves also… and i would need to set the state
to START_STATE again if no special move has been found…

yup.

Is this correct?

Just about. Unless you want to have multiple state machines running at
once, you don’t want multiple state variables: each machine can be in
one state at any given time.

My suggestion would be to figure out all of the moves you want, then
draw a picture. Several of the sites you’ve read should have given you
a good idea of how to go about drawing the machine on paper. You could
end up saving yourself a lot of work by drawing it first.

peace,
ah

ps. and keep the drawing around so that when you want to change the
state machine you can do it without having to figure out how things work
again :slight_smile:

Hi All,

Here’s one way to build your state machine:

Suppose we have the following special moves:
Left Down Right = Fireball
Left Down Up = Uppercut

Or, in other words:
LEFT->DOWN->RIGHT = Fireball
LEFT->DOWN->UP = Uppercut

We can build a state table for the moves.
Note that the blanks are 0’s in our table:

Keypress Current State
0 1 2 3 4
/----------------------
Left | 1
|
Down | 2
|
Right | 3
|
Up | 4

     ^^Next State^^ 

On the left side is the key pressed; on the top is the Current State,
and the table itself is the next state to go to.

Here is some code to implement this table:

/* ----- cut here -----*/

/* lets keep the state table in our code for future reference:

        0   1   2   3   4
    /----------------------

Left | 1
|
Down | 2
|
Right | 3
|
Up | 4

*/

/*
** defines:
** N_KEYS
** the possible ASCII codes - i.e., the keys on your keyboard.
** we want to be able to handle any keypress, and each keypress (unless
** we do some filtering first) gives us an index into our state table.**
** N_STATES
** the number of states in our state table.
**
** STATE_FIREBALL
** STATE_UPPERCUT
** our special states
*/

#define N_KEYS 128
#define N_STATES 5

#define STATE_FIREBALL 3
#define STATE_UPPERCUT 4

/* here’s our state table: */
int keyState[N_KEYS][N_STATES];

/* call this at the point of Initialization */
void InitStates () {
int i, j;

/* start out with all 0’s */
for(i = 0; i < N_KEYS; i++)
for(j = 0; j < N_STATES; j++)
keyState[i][j] = 0;

/* set up the rest of the state table */
keyState[ASCII_LEFT][0] = 1;
keyState[ASCII_DOWN][1] = 2;
keyState[ASCII_RIGHT][2] = STATE_FIREBALL;
keyState[ASCII_UP][2] = STATE_UPPERCUT;
}

int state = 0;

/* somewhere in the event loop */

key = GetKeyboardInput(); 

state = keyState[key][state];

switch(state) {
  case STATE_FIREBALL:
    doFireball();
    break;

  case STATE_UPPERCUT:
    doUppercut();
    break;

  default:
    doNormalMove(key);
}

/* ----- cut here ----- */

This simplifies your code a bit - you don’t have to decode your
switch statement if you want to change/add things. You would
need to decode your state table; however, it wouldn’t be too
difficult to write a Perl or Python program to process a series of states
which creates the table for you. If I get around to writing one, I’ll
post
it.


Now, suppose we have these moves:
Left->Down->Right = Fireball
Left->Down->Right->Right = Super Fireball
Left->Down->Right = Uppercut

Your table might look like the following:

        0   1   2   3   4   5
    /------------------------

Left | 1
|
Down | 2
|
Right | 3 5
|
Up | 4

Notice that all I did was to add another state and another entry into
the table. However, somewhere in the code we would have to reset
the state after a short amount of time - something like:

int timer;


switch(state) {

}

GetTimer(&timer);
if(timer > MAX_TIME_FOR_SPECIAL_MOVE)
state = 0;
ResetTimer(&timer);
}

You could use the SDL Timer functions (with which I am not familiar yet) to
do this.

Ciao,
Robin
@Robin_Sam