00:00
00:00
MSGhero
Free time is nice time.

Nick @MSGhero

Age 30, Male

Somewhere in the North

Joined on 12/15/10

Level:
17
Exp Points:
2,848 / 3,210
Exp Rank:
19,876
Vote Power:
5.85 votes
Rank:
Police Sergeant
Global Rank:
6,516
Blams:
456
Saves:
937
B/P Bonus:
12%
Whistle:
Normal
Trophies:
6
Medals:
661
Supporter:
11y 4m 28d
Gear:
3

Juggernaut Post Mortem

Posted by MSGhero - June 10th, 2013


or: I made a game and can't understand the code.

JUGGERNAUT: Awakening is the first of four games in the series made with VoidForce and Mattlaaa. It's a turn-based RPG with a few quests and medals to unlock. The story progression is pretty cool if you're into reading (if you've gotten this far, you might be). The code for an RPG usually doesn't have anything complex, just lots of tedious interactions. But when your code is terribly written, it starts to become a headache...

First compile: Nov 12, 2012
Last compile: May 31, 2013

We (I) went at a pretty relaxed pace since there was no deadline or anything. A lot of that time was either me trying to figure out how to do something or me fixing what I just broke. During the last few weeks, the game was up on FGL for potential sponsorships, but not many people want an RPG since the reading and filesize deter a lot of viewers, plus the game isn't THAT good. So, we put it in Mochi distribution to get it to spread while uploading it manually to the more popular portals.

Biggest problems:
Game was too hard, few bugs, kinda bland, slow-paced. There were some issues with balance initially, but you kinda get used to the game after a while of creating and testing it. But since every other comment mentioned it was hard, we lowered the levels and buffed the stats some. Not sure if it was enough, I think people are comparing the game to something like Pokemon where you can handle plenty of fights before getting healed up. The game looks and feels like Pokemon, so I guess that's a fair comparison. I'm definitely gonna push for mouse controls next time; part of the reason my code is terrible is that I couldn't use native events to control the flow of the game, and I had to store which button you were currently highlighting rather than the mouse telling me where it was. Apparently the keys are a bit awkward as well, I guess I just got used to them. And there are a few bugs, but I really don't want to look at that code anymore. The other issue was that it was bland, kinda generic. RPGs are all about cliches and tropes, but there wasn't really anything to set this one apart.

What went wrong: (a lot)
When you're making a prototype, it's fine to be a bit unorganized and ignore OOP. That's how it started, a demo of collisions using alpha maps. Then entering and exiting maps/houses. Then NPC interactions. Then quests. Then battle. Then items and the shop. Then cutscenes. Then saving and loading. Then the main menu and preloader. Then sound. Then fixing battles. Individually, a prototype for each of those would be fine since I was always experimenting with how to do them. But at no point did I refactor my prototyped mess. Every other day, someone would bring up a bug, most often in the battle sequence. Then I'd patch it up by adding a boolean or two to account for that corner case. Then those booleans created another corner case, etc. It was the equivalent of ignoring your car's windshield when it has a crack in it, eventually it spreads and you have to replace the whole thing.

Between when I started coding the game and when I thought I was finished, I learned some things. Applying those things while keeping the messy code from before is what confused me the most, to the point where now I can hardly understand what's going on. After getting virtually slapped by PSvils from 5000 miles away and remembering a discussion we had in Flash forum a while back that I kinda ignored (I'm an idiot, I know), I learned how to organize my mess for the future. Initially, I was going to basically reskin the game and add whatever new features for the sequel, but I'm gonna have to rewrite the entire thing to make any sense of the code. Organization, that is the lesson.

Another issue is that I didn't code with the future in mind. The more immediate future, like adding the next function of the game. With more forward thinking, my transitions wouldn't be hacky and all over the place. I would have structure in my code, not having half the variables persist after starting another save file (probably why the game crashes for some people, though I haven't gotten it to happen in 3 months of testing). I would have added functionality for the cutscenes to appear in battle: the pm containing "This cutscene will occur before the battle ends" made my code die. After that one, seeing that I had pms from Jordan in my inbox made me uneasy cuz it usually meant something else broke. And it always took me about a week to replicate the bug, longer to fix it. There are still a few bugs cropping up, but ehhh. I don't think redoing this engine for this game has much of a point: the game will probably be off the front page by the time I redo anything. Of course the next ones in the series will have a much better system. Idk, the code makes me queasy, but I feel like some people want to re-play the game bugless. I can go ahead and shelf it as a lesson learned, but is that selfish? I mean I've known about that bug for 3 months and it hasn't shown up for me once... *also I think some bugs are caused by not using the latest version of Flash player*

What went right:
The ideas that I prototyped are pretty solid. The alpha maps which tell the game about collisions and stuff worked fairly well. Any issues were usually resolved by "making the blue bigger" which was the color of the hitbox for certain things. The extra png per map would have been an issue with filesize, but they only contained like 5 colors tops and png compression is apparently really good. Without music, the game is about 1.5MB. I played around with the compression settings in Flash for a bit, but then I somehow fucked the sound quality to an unrecognizable state and it wouldn't revert. The total file size was under 6MB, but the audio was painful to listen to. But I had everything backed up in the cloud, so my mini heart attack didn't get any worse. So maybe it could have been a smaller filesize without making the audio sound like a dying hyena.

The cutscene engine I made is great compared to the rest of the crap that makes this game run. All the commands are in an XML file, and the code just reads the next line and executes the command rather than hardcoding everything (do people actually do that?). It never got to the point where I could tell the writer himself to add cutscene elements to the file; maybe with JSON it would be easier. However, I looked at the cutscenes more than 100 times each, so changing up the positions or how far the characters needed to move was easier for me to do anyway. It got messy towards the end when I needed to play sounds and show attack animations in a cutscene, but besides that, it's excellent.

Somehow it got frontpaged and daily 5th, so I guess that's cool.

And most importantly, I finished it. Since most of the image files were made before I ever needed them, there was never the bottleneck of me not being able to test something since I didn't have the art *cough*RobertSabrinaZachary*cough*. And the lack of a deadline certainly helped, especially since I had no clue what I was doing and Spring was my semester of death at uni. I mean, I still consider myself a fledgling game dev, so I'd say this went fairly well. This was a big learning experience for us (I don't know if Matt learned anything new about making music, but I learned enough to make up for that).

So, what's next? Refactoring the hell out of Juggernaut I's engine is pretty much necessary for the future games to be glitch-free. I think the art is mostly done already for II, so I have plenty of things to work on when we're ready to start it. Though we might go back and add some flair to the sprites.

If you've gotten this far, you definitely don't hate RPGs for all the reading involved. Go play one now. Preferably mine.


Comments

Thanks for the post! Reading about the mistakes others have made is always helpful to me since I'm a noob and will likely fall into much more traps than you have. :P

I'm glad my torment helps you out :)

I fell into the exact same trap for my other games, and 1 will forever be unpublished because I can't read any of the code, and it's bug-riddled.

Also it uses AS2 and I don't want to use AS2 anymore.

I have a graveyard folder of unfinished projects. I'm bringing one back to life, but yeah I have to redo all the code.

Very good, sounds like you learned a lot. Making rpgs is very hard, and the payoff is usually much less than the love and sweat and tears and pain you put into it. That is the nature of rpgs I think. Keep it up man, game was clearly a heavy work-load and most importantly you learned! Keep it up!

Lots of tears and pain. The future games should end up being easier on me and more stable, so I have that to look forward to.

Apparently you should use OOP features, human-readable variable & method names and lots of comments. Also - packages stored in folders. Making use of interface implementation feature would have helped a lot.

Everything was a bitmapdata, so I couldn't dispatch events easily, and I sorta handled it wrong as well. I had a few interfaces, but that was one of the things I added late, so it did about as much harm as good. Comments would have helped a ton, and not having 1000 line classes...

Dude, I have an old game which has all its code written in a frame - 16K lines of code. Not a single class instance is created - pure arrays, weird variable names, if constructs & function calls.
Guess what? I can add new features in it and even fix occasional bugs. Bug replacing/fixing parts of old code or change the overall structure of game's program is impossible, because I simply can't figure out what happens after what, which variables are used in which places, it takes ages just to scroll through it and find anything. You're telling me about 1K lines classes? That's small - pretty acceptable. Way to go.

I found this last night, and it seems to be relevant to your interests:
<a href="http://gamedev.tutsplus.com/articles/business-articles/web-game-sponsorship/">http://gamedev.tutsplus.com/articles/business-
articles/web-game-sponsorship/</a>

I also recommend a book: Refactoring by Martin Fowler
It's been very helpful with making my code easier to understand and test.

I actually read that a few days ago haha. I might look into the book, but I pretty much have it under control now. At least for now.

Still i burn this earth and fire!