Wednesday, June 18, 2014

So, you want to create a game engine?

Don't.

Ok, now that we have that out of the way, and I haven't convinced you not to, let's get this party started.

I'll be blogging a bit about my own experiences with making our own game engine.  It will be part technical, maybe part code, a bit of code architecture, motivating stories, demotivating stories, nuances, and all sorts of other things.  If anything, this will be used as a self-counseling and rambling type session, and if you want to follow along, feel free.

Usually you'll hear a sizable amount of pessimism from other people when you mention a desire to make a game engine. This is probably rightfully so.  As a solo developer myself, I will have to admit I didn't truly appreciate the sheer complex, massive task that this would encompass.  As of this writing, my own engine isn't "done", it isn't "feature complete", and has a substantial amount of things todo left.  However, my engine currently DOES fuel the backbone of a couple of cross-platform, published games - so it IS functional and even usable.

I suppose the first thing we need to focus on is just WHAT exactly IS a game engine.  I could probably list out a dozen or so references and copy pasta, but I generally like to rephrase things in my own words as I feel that once I believe I understand something, I should be able to reiterate it off the top of my head in somewhat plain English.

So, without further ado, a game engine is a large, complex collection of software that other software products (in this case games) utilize to deal with inconvenient and time consuming aspects of development.

When we save time, we save money.  An endeavor to make a game engine is a non-trivial obligation and decision to invest a substantial amount of time to save you time and money later.  Return on investment is the name of the game here.

Speaking of return on investment.  There are plenty of ready made engines out there.  You will likely see people advocating their use.  Things like Unity, Cocos2d, GameMaker, and various others exist.  If you are convinced you want to make an engine, you should STILL download some/all of them and look at them.  Look at the service they provide, look at the source code (where applicable), play with them a bit.  Get a feel for how they work and what they give you.  If you are to make your own engine, YOU will be making a comparable product, with similar interfaces, with similar needs and goals.  Think of this as competitive research.

If you look at the comparable engines out there, I hope you begin to look at how overwhelming the goal of making your own is.  "Look at all this stuff, I certainly won't need all this clutter!".  Trust me, I know what you're saying.  Chances are, you're right, you likely won't need a large portion of "all that stuff".  Sadly, there is a lot of it you will need, but you won't know that until you're well in to development (likely several months or even years).  So, look at these large projects and realize one thing.  There exists the potential that YOU will ultimately make something very similar in scope and complexity, you just don't know it yet!

"But all I really need is something to load up graphics and put them on the screen... my game code will handle the rest".  This is incredibly naive and very, very far from the truth.  I know, because I thought like this once.

The small laundry list of things you think you need will grow ever so slightly at first, but it grows at a consistent pace.  Oh, I need some abstract thing that handles generic box-like shaped regions (think clickable zones, usually useful for things like buttons)... yea, we'll need that... but what about font and text handling... don't really need TTF format support... or do I?  Should I want to load in custom bitmap fonts?  Oh, I need to be able to load bitmap formats (bmp, png, jpg?).  It will probably be good to be able to display those graphics too -- hmm, OpenGL, DirectX?  Is my engine going to be cross-platform?  If so, there are major implications for choices that I can make.

Surely, we COULD support DirectX with a cross-platform engine... but that technology would only be supported for the Windows versions of our games.  This sounds fairly straightforward, but it complicates things in your graphics code, build process, and even workflow when messing with your engine, and then ultimately building games using that engine - which of course is the actual goal when rolling your own engine.

I'm going to make more articles about specifics as I go, so don't worry.

For now, know this.  The game engine I'm currently working on, and actually using, is my 4th attempt at making an engine.  It is by far the most complex and furthest developed one I've ever made (none of the other ones actually fueled any games!).

I highly recommend you not grow too overly attached to any engine you make right away.  The first engine or two you make should really be seen as a learning experience because you will need a deep appreciation for the overarching goal and understanding of what it is you need to do and actually CAN do before you can make something actually usable.

Look in to version control software.  I'm using the very awesome mercurial to track changes in my engine code (and to keep my own general sanity).  According to my commits, my current engine was first submitted to version control on 17 August, 2012.  As of this writing, it will be hitting its 2nd birthday soon.  It is still not "complete".  We have a ways to go still; especially in 3d support and having support for playing back avi/mpg files in games.  There are plenty of other things left to do as well, some of which I probably don't even know yet, but we'll get there.

What I hope you take away from this article is several things.

One, making a game engine is not trivial.

Two, making a game engine is vastly time consuming, likely taking years of fairly hard work and lots of research.

Three, making a game engine is a lot more complicated than you realize.

Four, be ready to admit your ways are wrong, to incorporate new ideas, and be ready to gut things that aren't working in favor of newer, better ways of doing things.

Five, if you're weak of heart and don't have borderline OCD, this probably isn't for you.  If you're even somewhat on the fence about this whole thing, you will likely only find disappointment.

Oh, and lastly, you should consider using other game engines still... but if you're still not actually convinced and you still want to venture forth in to this crazy goal... then by all means, let us proceed!

Next article we'll talk about choice of technology and actually getting started making your own game engine through my ramblings about how I got started with my own.

It is not for the feint of heart, but here you go, the dawn of a new game engine!







No comments:

Post a Comment