cracklestudios

Hello,

I have been working on a sort of fighting game and now i don't know how to do the Input. It's a windows game so I use keyboard input.

What i need is A for punching and W for kicking preceded by a left/up/right/down key to make different punches/kicks. So first tap one of the arrow keys and then tap A/W to make a move. ((If no arrow key is pressed do a default punch)).

How can i do this I tried a lot but I don't know how to recogneize which combination keys the user tapped.

greets jeroen.




Re: Game Technologies: General Input for fighting game

George Clingerman

Are you using DirectX or XNA Game Studio





Re: Game Technologies: General Input for fighting game

waruwaru

Look up "state machine". The basic high level idea is, each time you press a button, you move your fighter to the next state depending on the key. So, states might be something like:

Standing_State + (A) -> Punch_State

Standing_State + (W) -> Kick_State

Standing_State + (Left) -> Special_State

Special_State + (A) -> Special_Punch_State

Special_State + (W) -> Special_Kick_State

You perform proper animation for each state.

There are also a few open source fighting games which you can look at to see how they control the moves.






Re: Game Technologies: General Input for fighting game

cracklestudios

I'm using XNA gamestudio.

I know about the states/actions of the palyer but my problem is somewhere else. When I hold my A key the character keeps throwing punches. I want my character only to punch when I have released my A key and left/right/up/down key before i press left/righ.. + A again. But I don't know how to do that. For a key-release event I use:

if (newKeyboardaction.IsKeyDown(Keys.Left))

{

//left key pressed

}

else if (oldKeyboardaction.IsKeyDown(Keys.Left))

{

//left key released

}

I think my problem is in here. Because oldKeyboardAction is the newKeyboardAction value of every previous loop. I hope it's clear.

 

Jeroen






Re: Game Technologies: General Input for fighting game

George Clingerman

If you want a punch to be thrown only once when the use presses the key and never again until they've released the key and pressed it again then you want to do something like this.

if (newKeyboardaction.IsKeyDown(Keys.Left) == true && oldKeyboardaction.IsKeyDown(Keys.Left) == false)
{
//throw a punch
}

okdKeybaordaction = newKeyboardaction;


Hope that helps you out.






Re: Game Technologies: General Input for fighting game

cracklestudios

That's what i needed. Thank you.

Jeroen






Re: Game Technologies: General Input for fighting game

cracklestudios

There's some progression now and my Input code has to be updated since I want to use combination keys to attack. Imagine like this; left+A=left punch | right+A=right punch | left+up+A=left uppercut | right+up+A= right uppercut.

I was thinking about declaring an array pressedKeys[]. Every key that's pressed is added to the list and will be 'inactive' after 0.25 sec (for example). When a combination is found do the action.

Is this a good way to do this If so, what is the best way to use the array and detect combinations. If this is not the way, correct me ;-)

Jeroen.






Re: Game Technologies: General Input for fighting game

Calvin Bell

Idea for you!

Put them in a queue lets say 10 button presses long. When you hit a new key, dequeue the oldest one and enter the new key pressed. When a new key is enqueued, check the past couple (two, three whatever) spots in the queue to see if it equals a move. The reason I was thinking this is in Soul Calibur, in the practice mode it scrolls your button presses across the bottom of your screen like a big queue. New moves in the front old moves out the back.





Re: Game Technologies: General Input for fighting game

Fluxtah

Similar to the post above you could make an array to serve as a key combination buffer, with a timer possibly to determine when to evaluate the contents of the buffer for a valid combat move.





Re: Game Technologies: General Input for fighting game

Inaki Ayucar

If you want to use DirectX and make some serious Input manager for your application, Ií»ve posted a "Custom Action Mapping" tutorial in my blog:

http://graphicdna.blogspot.com

(Search the Input tag)

It is Managed DirectX based, so it can be easily ported to XNA.

Regards.






Re: Game Technologies: General Input for fighting game

cracklestudios

I re-organised my project and improved some things like loading the sprites(now from 1 image with all frames) and the new input is almost done but I don't know how to set some timer on the keys.

What i did is very simple. I have an array keyBuffer[5] and a function addKey(string keyName) to add a new keypress in the array and remove the oldest. Everytime addKey is called there's a check for combinations.

In my input  it is like you have (for example) 0.5 sec to enter a combination key. The way for me to do this is like  every 0.5 sec a keypress named "none" is added to the keyBuffer so the combination has become invalid.

 

So the question is;  How can I set a timer that will do addKey("none") on every interval .

                                  Is this the right way to create this type ofinput   (using addkey("none") every 0.5 sec)

 

edit: I realise now that this timer could come with some problems,,  if you start your combination key on the 0.4th sec you would have 0.1 sec to enter the combination!  Can anyone help me with some better way to do this input thing

 

greetings, jeroen