turning button presses into attacks - fighting games
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.
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?
heh, i know that much ![](smile.gif)
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
![](smile.gif)
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.
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![](smile.gif)
MENTAL
sorry to be sarcastic, but i never worked out the logistics of it. 4kb really isnt that big at all
![](smile.gif)
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![](smile.gif)
MENTAL
![](smile.gif)
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
![](smile.gif)
MENTAL
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...
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?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement