Skip to main content
GameDev.net gamedev.net
🔒 Locked

Input engine

Started by IncarnateRW Mar 11, 2003 at 2:00 PM 2 replies 350+ views
Original Post
IncarnateRW
IncarnateRW
Hey all, I am making a fairly simple fighting game to get the feel of directx and such, but I''m having a LOT of problems coming up with a viable input engine. I have a number of moves, each with their own animation. When I get input, I have to figure out which animation it corresponds to, and set the animation to that. The problems come when I get input during an animation ie: the player presses kick and then punch while the kick animation is still running. I cant just switch over, so I have to buffer this input somehow. I have tried 3 different configurations for this buffer, and none of them work very well. I don''t seem to be making any progress so I was wondering if there were any good articles or anything on the subject of input engines. Im lookin for general theory of how to buffer what, and what kind of information I need about the state of the player and the moves. Thanks
marcus12024
marcus12024
Maybe this seems too simple...but why not just create a boolean variable that gets turned on when an animation is playing (ie: a move is being performed), and shut off when the animation is finished. Unless your fighting game is really different then all the other ones out there, you can't usually perform another move while the first one is executing...unless of course you're looking for something similar to Killer Instinct's combo system?

If so, try something like this:


    
// #defines for the move animations

#define PUNCH 0
#define KICK 1
#define FIREBALL 2
#define UPPERCUT 3

// array to hold the moves to be performed

int moveBuffer[10];
int moveBufferIndex = 0; // current index of the moveBuffer


// indicates if animations are currently playing

boolean animPlaying = false;

....

// now in your code for checking for keys, input, etc.

if (punch) {
if(!animPlaying)
// no animation currently playing, so play punch animation

else { // animation already playing, add a punch to the buffer

moveBuffer[moveBufferIndex++] = PUNCH;
animPlaying = true;
} // end else

} // end if (punch)



Now just repeat this for all other possible moves for the character. You'll probably need special cases for things like which moves are allowed to follow others, but this should at least get you started.




"The power is not in knowing what to do, but how to do it." -ME

[edited by - marcus12024 on March 11, 2003 12:22:34 AM]

[edited by - marcus12024 on March 12, 2003 3:50:43 PM]

[edited by - marcus12024 on March 12, 2003 3:51:28 PM]

[edited by - marcus12024 on March 12, 2003 3:51:50 PM]
Life's Short. Make Games.
IncarnateRW
IncarnateRW
That was my first idea. The problem, as you mentioned, came when a move was placed in the queue that could not be performed after the moves in the queue in front of it were performed. For example, when the player hit kick, crouch, kick, all before the first kick finished, then MID_KICK, CROUCH, MID_KICK would be placed in the buffer. however, the second mid kick could not be performed while the player was crouching, so that move would be lost.

You''re post did get me thinking though, and I have a new idea. Instead of making one structure for each individual move, I''ll make one for each individual keypress. that way, I can just buffer the keyPress structure, and when it is taken from the queue, the move for the appropriate state can be found within it. Thank you very much, I''ve been thinking about this problem for 2 days straight now
TalonSnow
TalonSnow
Sorry if this isnt helping much, as i jsut cruised through the posts real fast. But why dont you have a seperate structure for Target Area? That way you only place punch, kick, etc.. in the queue, then when it extracts them it looks at the Target Area Struct and applys it to that area. That way when you place kick, duck, kick in before first kick is finished, when you duck, it assigns target area to low, and final kick will be delivered low

Hopefully this ramble with no code backup made sense
<=- Talon -=>

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.