Making a fighting game. With or without AGS.

Started by 2ma2, Sun 19/08/2012 19:24:01

Previous topic - Next topic

2ma2

The idea of making a fighting game intrigues me, but I saw it fitting to start a new thread for it. This will not discuss what functions to (ab)use, how to make character X do Y when button Z is pressed or whatnot, but rather discuss the underlining framework for a fighting game.

The first issue to address, long before background graphics and sprite animation, is how to map hits. My first thought is to have relative coordinates for attacks and fully transparent placeholder areas:

Let's say a character is placed on (X,Y) at a given time. We now have a series of possible attacks - high punch, low punch, high kick, low kick etc. Each of these needs to have a fixed relation to (X,Y) when the character faces a specific way.

Let's say the character faces right.

Low kick (X + 50,Y) - the low kick will hit if the opponent is 50 pixels to the right, and not in the air since Y is at ground level.

So what is the opponent? A rectangle the height of the character, or some sort of polygon better suited to map out a body? Either way, whether each attack will hit is whether or not the coordinates of the attacks is within the placeholder area. Using another character as a placeholder and hiding it with the walk-behind masks is a nice way to go about - it can even be dynamic by switching sprites, so the area changes when jumping, crouching, doing flying kicks etc. Nice to pull off an uppercut into the groin of a high kickin' opponent! :)

Then we make the game balance asymmetric by character specific variables - each fighter has a different delay from button press to finished blow, how much impact each attack has, the size of the placeholder area etc. From a swift and vicious, slim martial artist to a huge brute, with larger delays in the attacks, but with massive damage once a punch lands in someone's face.

Do any of you have first hand experience of coding a brawler, and what kind of neat feats and tricks of the trade have you gotten hold of?

EDIT: Tidied up the language a bit.

DoorKnobHandle

#1
There was a thread on this recently but it wasn't exactly fruitful. Here's a link to what I wrote in there.

The way I did it in that Street Fighter II clone was to give a simple hit box to each character (just one rectangle as both characters are fairly square and when players duck it simply shrinks). And then the game stores a hitbox for every attack as well, this information could look like this for a punch for example:

Code: AGS
#define PUNCH_HITFRAME 3
#define PUNCH_HITBOX_X1 5
#define PUNCH_HITBOX_Y1 -25
#define PUNCH_HITBOX_X2 7
#define PUNCH_HITBOX_Y2 -29


So when the player or AI throws this specific 'punch' attack, the game will wait for the frame where the actual impact is occurring (in this case it's frame 3 of the punch animation), and only while that particular frame is being displayed, it will have a hitbox with the given dimensions respective to where the attacking player is located at. Then the game just needs to check whether or not any current attack hitboxes overlap with the player hitboxes, deal damage, stun the opponent etc. if that is the case.

That's the basic gist of how I did it, no idea if this is how it's commonly done in fighting games but it works well. You should invest time into working on a very good debug mode for your game that draws out all the hitboxes and additional information (such as current animation set and frame), because fine-tuning the attack hitboxes can be tricky otherwise. Also make sure you mark frames as 'done' when damage was dealt in them, you don't want the game to deal damage every frame that is drawn while the two hitboxes overlap, once per attack animation is enough.

This concept can easily be improved upon, allowing attacks with several 'impact' moments (a spin kick that hits with both feet for example) for example.

Hope this helps you out.

m0ds

Jan knows his fighting game shiznay! :)

Hope you go for it and produce something new Mr Linus!

ig299

Kinda complex but i'll take it into consideration.

2ma2

@dkh: Cheers! :D Using vector maps is cool, because it ought to be memory efficient and it'll easily give for multiple areas substituting as a body. One could then adjust attack result for whether a flying kick lands in the gut, chest or head. I also like to use the animations themselves as timing devices for attacks, because if they are interrupted, you don't have to script the timer cancellation, you just start another anim for that object/char.

Yeah, the debug would also be efficient to tune character balance later, such as making sure the largest fighter's high attacks always misses the smallest etc. I'd like to force the player to adapt his tactics not only to the character he/she plays, but to the enemy he/she faces as well.

@Mods: It's more of an interest on how to go about for now, but we'll see what happens ;)

@ig299: When starting making a game, turn off the computer and sit down with pen and paper :)

ig299


2ma2

It means that before writing a single line of code, you must have a rough idea of how the game should work, especially if you need to make the engine by yourself. AGS was made to simplify the creation of point-and-click adventure games in the vein of the 80's and 90's. There are other engines that might simplify the creation of brawlers and fighters as well, but if we want to make a proper solid fighter with AGS, we need to think about not only how the characters may move about on the screen, but also how they may punch and kick their opponents - and block or dodge punches and kicks.

Just testing whether or not a pixel of a character is at a given location is not entirely beneficial. That would make you able to hit details that does not matter, such as ribbons, a cape or chains for instance. Things like drawn "motion-blur" and speed-lines are also best placed within the actual character sprites, but not something you should be able to hit.

So one sits down with a notebook, a pen and scribble down ideas. When something seem to make sense on paper, start AGS and write the code. Then test it out with some friends. It probably fails miserably, but we have a better foundation to track down WHAT fails and HOW we can change the overall design to make it WORK.

R4L

There's always Beats of Rage and MUGEN, the latter being the easiest to use but not exactly the best. You can go on youtube and watch thousands of mugen videos with broken characters. But whats the fun of using an already built engine? :)

SMF spam blocked by CleanTalk