Advertisement

turning button presses into attacks - fighting games

Started by March 10, 2001 06:30 AM
6 comments, last by MENTAL 23 years, 11 months ago
argh! i cant get my head around this one. Think of a fighting game like virtua fighter, dead or alive 2, soul calibur, etc (i refuse to mention the "T" word). okay, now you know what i mean by fighting game. anyway, in these games each character has a massive amount of moves, all of which require different button combinations. here comes the big question: How the hell do you store the data and work out which moves are to be pressed? the only thing i can logically thing of is if you use a giant linked list for each button, but if 2 buttons had to be pressed, it wouldnt really work :/ Any help appreciated MENTAL
Well, if you play Tekken (probably the best fighting game ever) on practice mode, you will see a string of button icons denoting the order in which presses are made.

If you store a button list and set of timings between each press for each move, then when buttons are pressed, search the move list for one that matches (and the timings are within a threshold), and that''s your move.

A button press can be any combination of buttons, just like the Tekken icons.
Gee Brain, what we gonna do tonight?
Advertisement
heh, i know that much

the problem i''m having is HOW to store the information. linked lists seemed logical (rather than a massive array of every combo). LL is also much more flexable

MENTAL
I''d use an array. Two bytes per button press (one for buttons, one for timing). Say, an average of 4 presses per move, and 500 moves, that''s only 4000 bytes.

The array for each move only needs to be as big as the number of buttons required.
Gee Brain, what we gonna do tonight?
okay smart-ass, and how do i add "forward and punch together" into it?

sorry to be sarcastic, but i never worked out the logistics of it. 4kb really isnt that big at all

MENTAL
nm, i''m just gonna add another byte called direction. if it''s just a directiont hat needs to be pressed, the appropriate direction will be entered, and button equal to zero. if just a button, the button entry will be made and direction zero. if dir + button well i suppose i''ll fill in both .


the only other prob i can think of is simaltainious button pressed (like A and B together), but if i''m doing a bunch of #defines for the buttons/directions, then i''ll just add #define BUT_A_B 1 or something like that


thanks for the help, this was really getting on my nerves

MENTAL
Advertisement
Store each button press like this

1 byte = buttons:

bit 7=up
bit 6=forward
bit 5=down
bit 4=back
bit 3=Punch 1
bit 2=Punch 2
bit 1=Kick 1
bit 0=Kick 2

1 byte = timings:
Whatever you like

class button
{
byte buttons;
byte timing;
}

Then for a standard fireball move (D,DF,F+P), just store a 3 element array of button. The first element has buttons=0x20, second has buttons=0x60, third buttons=0x48

for example...
Gee Brain, what we gonna do tonight?
never thought of using individual bits for it

MENTAL

This topic is closed to new replies.

Advertisement