06 Jan 2023 - TUNING DIPSW (Andrew Hsu)
Good day. In this series of articles, I’ll be attempting to program a simple 2D fighting game using the Python game development library Pygame, documenting the process as I do so, working through the problem, the logic, and the code. There might be some arbitrary flavour tangents included as well, as I am not being paid to omit them.
…And here’s one coming up fast…!
(Note: This is a long one. Feel free to skip to #0.5 or a later segment using the Table of Contents above.)
The fighting game genre boasts a storied legacy that few others can match, with its Street Fighters and its Tekkens, its King of Fighters and its Smash Bros. And it doesn’t take long for onlookers to understand what a fighting game is about; the thrill of combat between two foes standing face-to-face, the back-and-forth drama of two rivals going blow-for-blow can pull them in without explanation. It’s famous, simple, and it’s been around for quite a long time. Between those three factors, I think it is a contender for the most recognizable genre there is.
And yet, despite the purchase the fighting game has in our cultural consciousness, the fighting game genre has a reputation for being one of the hardest to get into, and in recent years, it seems like one that only a handful of big companies dare attempt.
Yes, recent fighting games have had their successes, as of late.
However, this is but a sample of the biggest games, made by the most skilled companies… and only of sales, not of playerbase.
I don’t want to bring out the Steam Charts(tm), but you don’t have to look far to see how players flock and have flocked to other genres, like the FPS, the Facebook game, the MOBA, the gacha game, the battle royale, the auto-battler, the Vampire Survivors…-like, whatever breakout hit you see creating its own genre of derivatives and imitators…
and you might wonder to yourself, why make a fighting game?
Who is going to play my game?
Sometimes I wonder how fighting games are doing. Perhaps you wonder sometimes as well.
The golden age raised a generation of fighting game players we still tell stories about today. The arcade generation, the four Japanese gods, those Umehara Fighting Gamers… The revival era sparked by SF4, too, spawned its own renaissance of competition, where it seemed like SF4 was the world. But those days are behind us, of course.
Now, today, Street Fighter 6, Tekken 8, and Project L loom on the horizon with great promises and expectations for each – New mechanics! New characters! Smoother netcode! New old characters! Better features, a better package! Photorealistic images of Ryu’s sweat glands! A fresh new intake of players! – with the hopes that finally, with this title, the golden age might return again.
…Perhaps.
As multiplayer games, I think fighting games have it rough.
We core fighting gamers go into them looking only for their multiplayer, ignoring or downplaying the package, the single-player elements, chasing the memory of that fresh new competitive scene we’ve been longing for, just like the one that made us fall in love with fighting games…
Soon we’re crying for balance, crying for content, new characters, old characters, calling for the heads of the developers… Where’s Mileena, Ed Boon?? Daisuke’s vision, am I right?! When’s rollback, Kamone?!?! Oh thank you so very much, Mori…!!!!! Ha… ha ha hahahahahahahaha…!!!
But the modern fighting game had to evolve, has to patch, has to bow to the crashing waves, because they live and they die by the love of their playerbase……
The fickle dissatisfaction that can drive a thousand bitchmad Twitter users to call a game dead lives in the same heart as the love that lets fifty immovable Discord users continue to boot up and play sets with one another, peer to peer, long past the point of end-of-service, longer than any developer could realistically dream that their game could be played.
Atop the pile of a thousand defunct live service games (some middling fighters among them), lies that enviable summit which the most immortal of fighting games have achieved - those that have inspired people to play them into eternity.
Look at Eternal Fighter Zero’s Latin American community, look at the arcade goer who plays Street Fighter II Turbo every day, for thirty years – and I can’t help but think that the core fighting game player has something in them in common with a speedrunner.
The pursuit of perfection that drives a player to endlessly hone themselves, the dream of someday becoming unbeatable through one’s depth of experience and intimate mastery; that, at least to me, is the romance of the fighting game genre – and it abrases with the idea of an eternal revolving door of new fighting games.
Every new fighting game that comes out today must compete, in at least some way, with the decades of legacy that comes before it.
Your game, if you choose to go through with making it, must do its utmost to make the world care about it for even a moment. It’s fighting against Melty Blood Actress Again Current Code, against Street Fighter 6, against Yomi…Your Only Move Is Hustle; it’s fighting against Phantom Breaker Omnia, although this is a game that to my knowledge has little more legacy than its exceptionally camp release date trailer, one Vortex Gallery tournament, and a Will it Kill? clip, so this is not an exceptionally high bar to clear.
But even supposing that the core fighting game player gives it an honest try, and perhaps even enjoys its discovery honeymoon – In the end, those oldheads, who once were young, who’ve already found the fighting game they love, will surely seep back to the embrace of their old lover…
I don’t wish for you to take these musings as doomsaying, that I believe fighting games are dying. I don’t believe that fighting games will die. There’s so much enthusiasm and passion for them today, in this silver age of rollback netcode and (comparatively) positive discourses. I think there’ll always be a faction of goinmul players who’ll keep playing their games for as long as they can. I expect great things from the upcoming generation of AAA fighting games. But, I’m not convinced that they can sweep the world again like contemporary or future genres have, or will. Even though they’re such beautiful games.
When I look around the fighting game space, there’s a lot of things that make me uneasy about its future.
Netplay can be alienating, yet offline play may be uncertain.
Arcades are already on their way out,
the professional scene survives in no small part on the good graces of corporate eatsports interests,
and the tremendous effort required to run the events that carry our scene cannot be taken for granted.
Yes. I feel a little uneasy about the future of fighting games.
But you don’t care about that.
You mustn’t care about that.
If you’re here reading this, then you must already want to make a fighting game. You may not be aiming to make the next Street Fighter, or a title so successful it earns you ten billion dollars, or a game so excellently balanced that will-be oldheads point to it in internet arguments about how amazing/crappy the actual next Street Fighter is – but surely, on some level, you must have a love for the game. You must have a love for watching two characters speak to one another, through the rule of beasts, and that precious spark within you, wishing to make that happen yourself.
I cannot promise that making a fighting game will make you rich, or even that it’s a sustainable way to support yourself. It is unreasonable to expect that your self-made fighting game will be able to compete with the titans of the genre.
Nor can I even say that making a fighting game is a good idea. I write this text only because I am less sane than anyone whose judgement might be better.
But if you have a character you want to see expressed through the language of a game – a character from a series you love, an original character of your own that you can call a child, if you have a love for that character, if you have love, then make this game, and pray that that feeling can transmit to someone else out there, out in the world.
If there’s a part of you that screams when you witness an unbelievable combo on Will it Kill?, a part of you that could love a kusoge, that can feel the electricity running between the hands on your controller and the character on your screen, that wishes to see a game achieve the miracle of existence, against all odds…
If you have a love for the game, like I do, then let’s make a game.
Let’s make a beautiful game.
Firstly, I must say this. I have little to no fighting game player credentials. Frankly, I am quite poor at the games I play. Nor do I have much in the way of programming credentials. I still count myself among the beginning ranks of the profession. Is this fraudulent? Disappointing? Yes. Perhaps.
But I think many subjects suffer from a lack of mid-level educational content.* While there’s tons of tutorials for newcomers, and maybe even a handful of high-level, highly-specific technical discussions by subject matter experts**, a journeyperson who’s broken out of the beginner-level “tutorial zone” may find themselves frustrated by a lack of obvious, discoverable resources suitable for their level.
How do they learn? How do they learn how to learn?
I’ve found this to be true of both programming and fighting games, at least for myself. That’s why I’m starting this series. Though I have no accomplishments nor expertise to my name, the act of putting this resource together might still prove useful to someone, if only myself; and if it fails, stalls, or falls short, then, well, probably nobody will see this, so it shall be no sweat off my brow anyway. Even then, I might learn something in doing so.
Let’s begin by answering some preliminary questions.
Sorry, no, this isn’t the tutorial either.
This is because Guilty Gear XX Accent Core +R is my current favourite fighting game, and also because 2D fighters are the ones I have the most knowledge of. In comparison, I know much less about 3D and platform fighters; at best, I might be able to write the occasional addendum or errata where one of my 2D-centric comments does not hold in 3D or platform fighters. I also have a terrible gap in knowledge about tag fighters. But we’ll get there when we get there.
I will do my best to write a few comments on the differences between the various subcategories of fighting games, but in the end it will fall to you to fill in the gaps. I hope that the rigors of 2D that I provide will be enough to tee you up for whatever task you choose for yourself.
It is not necessary to learn how to program at the low level of any programming language in order to create a fighting game; many excellent and free game engines, libraries, and frameworks are available out there with a wealth of tutorialiterature to learn from, although I cannot guarantee that they will have up-to-date tutorials specific to fighting games, and it feels a little disingenuous to ask you to learn All of (eg.) Unity through overly-general tutorials just to learn how to make your fighting game.
Fight of Animals and Fight of Machines were made with Unity + UFE; Among Us Arena Ultimate was made in Unity directly.
Although not a traditional fighting game title, Yomi Your Only Move Is Hustle was made in Godot.
Sarvets All-Stars, one of the auction tournament games of Combo Breaker 2018, was made using MUGEN, and Battle Craze, as seen on Will it Kill Episode 17, uses SUEHIRO’s I.K.E.M.E.N GO engine.
Then, why use a programming library like Pygame? I will not sugarcoat it for you - it’s no small deal of grief to work with code directly. “True” originality is overrated, and though it may be satisfying to your ego, as a developer and a programmer, you ought to avoid reinventing the wheel when possible.
However, even so, there is something to be said about the satisfaction that comes from building something from the ground up, the degree of control and understanding afforded to the programmer who starts from scratch. I think there’s a lot that we can learn in doing so, even if it may be faster and/or easier to start with a more approachable offering.
As for the choice of Python and Pygame – let it be said that if there is a will, there is a way to make a game with any tool given to you. For example, the cult classic shmup Hellsinker., one of the greatest solo indie games of all time*, was written in Delphi**. Just finishing a game, any game at all, setting aside the merits and difficulties of whichever particular medium you choose, is an achievement that deserves celebration.
But the last thing I will ask you to do is write a video game in (eg.) C, because
You can use any tool you like, but you probably shouldn’t choose something that only adds pain.
There might be some things you truly can’t do anything about, but unrelated, unfair pain points can and will wear down your willingness to work on your project, and you absolutely must guard your motivation with your life. If you run out of motivation, there is a very real risk that your project will remain unfinished forever.
Don’t agonize over the decision forever, but if you take a bit of time to pick your tools with some thought, you can save a lot of pain. And when you do come across pain points, take a bit of time to stop and identify them, and perhaps invest a bit of time into reducing the pain to the best of your ability.
Now, I consider Python to be a good starter language for a host of reasons:
There are surely a feast of wonderful languages that fulfill these criteria – like Lua, for example, which offers the excellent LOVE2D library used in the top-notch shmup BLUE REVOLVER (among others). I’ve chosen Python and Pygame for its comfort factor, and in truth, this is the most important factor.
Overcoming the learning curve of other, perhaps clunkier languages can definitely be done with a little bit of stick-with-it stubbornness; if this is what you choose, you should still be able to get something out of the problem statement and logic portions of each update, with just a little bit of extra elbow grease to adapt the Pygame code to your language. But you can do it. I have a baseless faith in your ability. Nevertheless, I encourage you.
Please feel free to write in with YOUR factual opinion about what the BEST first programming language for new devs is. Or make a YouTube video with a loud thumbnail on it and reap those 15 cents of AdSense revenue. Either/or.
* A technical article addressing PyGame and its reputation for being a slow library can be found here.
You are free to use the code in this tutorial however you like. (That’s the MIT License included in this site’s repository.) An acknowledgement of credit would be a nice gesture, but I can’t really stop you if you don’t add one, and in the end it’s not a big deal. But if these articles were useful to you, then I would love to hear about it. Write in! …Somewhere! I’ll have to figure out an inbox or a comments section for this at some point.
If you steal and claim credit for writing this tutorial I’ll be pretty miffed at you. I’m not going to send you death threats or hire a dark web hitman or whatever, but like, come on. Let me have this.
If something isn’t clear to you, leave a comment and I’ll do my best to answer. I’ve added this grossly Wikia-looking Disqus integration to this end. I apologize for this affront to your sensibilities.
If you know a better way to do things, feel free to let me know as well. I am not an expert programmer, and there’s many things I don’t know. If the suggestion is good, I’m happy to update the relevant posts with better code or better information.
» Next: #0.5: Preparations