New code architecture for The Fifth Exponent

New code architecture for The Fifth Exponent

It’s been a long time with no update on the blog, but it has been very busy. I’ve been working on a post-jam version of the Fifth Exponent. I came attached to this little game with it’s quirky characters and think it has some potential, people judged the humor very well on Ludum Dare (it was ranked #34!) so I really wanted to put it into finished state. There was a lot of work to be done, most of it unseen.

In fact, after finishing Ludum Dare I started adding a few new features, especially the time rewind and hints. It wasn’t easy but it worked, and then during thorough playtests I’ve found out that the existing code was just impossibly buggy. And it just seemed impossible to correct with small fixes.

I have created my “adventure engine” during Resist game jam, which I have just adapted a bit in between. It has served me right during Ludum Dare #38 to create Six Degrees of Separation Between Me and The Party. For the Fifth Exponent though, where 2 characters are moving, animating and performing actions at the same time it just wasn’t sufficient.

So I came to realize that it had to be changed. At the same time I was reading a very good book, although somewhat outdated on certain points: “Mastering Unity 2D Game Development” by Simon Jackson. I was reading it and regreting not having read the book a year earlier when I started learning Unity. At the same time I’m conscious that reading the book when I didn’ know anything about Unity, probably would’t have worked for me, as I like hands-on experience, and turn to books when I need to deepen my knowledge. So I guess it’s only with my current experience of the tool that I find some of the hacks very interesting. The book uses Singleton pattern but mentions brefiefly Dependancy Injection and that’s what put me on track of searching for a better code architecture.

Well, my old code relied on the Singleton pattern heavily. I didn’t really think much about the impacts of this solution. The truth is, when I first started using Unity, I have been rather disturbed by the fact that there was no static Main function, no “starting point” function. My previous experience where with C, C++, Java, Actionscript… and even though apart C, others are Object Oriented they all have a static Main function, the root that is first loaded at the start of the application. So when I found a tutorial from someone at Unity using the Singleton pattern I just took it and implemened it without much consideration.

Recoding that engine nearly from scratch took a lot of time (spare time, but still most of my spare time), where you don’t really see the result for a long time. But when all the objects start to communicate and the game just comes to life as all by itself it’s kind of magic and a very pleasant moment. At least for me.

Now I’m doing the polishing, adding new features, and guess what? They really are easier to add in this achitecture!

Anyway that’s all from me, now that most of the code is done I’m febrile about it being nearly there after all this time. The PC version will be available much sooner then the web. I’ll need to figure out the persistent data save and create some medals for newgrounds before that.

I hope you found this post interesting. I suppose I should be writing these posts more frequently but shorter, but sometimes I just prefer to use the time on developpement instead. And I don’t know if anyone is actually reading these 😉

Here are the links to some great developpment ressources in case you found them useful:

Comments are closed.