Sign in to follow this  

How do you create a stack for recording movements [In fighting game]

This topic is 3845 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

As the subject is written. How do you create a stack for recording, reading, what actions has been used, as in what buttons has been pressed, etc... Record the button pressing? In an array? I'm wondering how to do this.

Share this post


Link to post
Share on other sites
Here's some pseudo-code describing the general form of an array based stack and queue.


// A stack using an array

datatype stack[MAX];
int index = 0;

// Push:
ASSERT(index < MAX-1);
stack[index++] = temp;

// Pop:
ASSERT(index > 0);
temp = stack[--index];

// A queue using an array

datatype queue[MAX];
int head = 0; int tail = 0;

//Put:
ASSERT(tail < MAX-1);
queue[tail++] = temp;

//Get:
ASSERT(head < MAX-1);
temp = queue[head++];



Share this post


Link to post
Share on other sites
not only that, but an array-based approach limits the number of commands you can have. Think of the complex joystick movements that fire off characters' secret moves. You run the risk of overloading your array. I would go with the stl queue.

- Goishin

Share this post


Link to post
Share on other sites

This topic is 3845 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this