So you want to make a game engine? Part 1 – Intro

[Sorry, started posting a week before the third blogging period began ._.]

Introduction

Hey everyone!  I’m going to do something a little differently for my five-week-long posting extravaganza.  I’m a computer science student, and naturally I enjoy taking concepts from classes and putting them to good use in my own personal projects.

A long time ago back when I was a senior in high school, I was taking a computer programming class.  Well, more accurately, I was developing a Pong clone in the back of the class while the teacher was rambling on.  Looking back at that code now it was really crudely thrown together, but it worked.  At the time, I was impressed that I’d developed an actual game.  It was technically multiplayer-only: one player used W and S and the other used Up and Down to control their respective paddles, meaning that’s all me and the friend next to me did for most of the remainder of the class.  Somehow this escalated into the class taking a day off from the course curriculum to have a Pong tournament using this game I’d made, to find the best Pong player in the class (it wasn’t me).  The knowledge that people were playing and enjoying something I’d created was an awesome feeling, which really made me feel like software and game development is the right choice for me.

Since that event, I’ve looked at the core game code I’d written and tried to get it into an external library (a DLL) that I could reference from future projects.  Over the years I’ve written and rewritten it so many times I lost count.  Occasionally I’d come up with major changes which would definitely improve it but involved rewriting everything.  Often these changes reflected the concepts I’d learned in my CMPSC classes.

After four major revisions throughout the course of my computer science career, I think I’ve gotten it to a pretty good point.  It evolved from a Pong game to a fairly flexible (but pretty simplistic) 2D game engine.  It uses object-oriented concepts efficiently and is fairly clear and concise for something that’s been picked and torn apart dozens of times.  Since I can’t think of much else I can share here at the moment, I think my 10 posts will be discussing simple game engine development: from the core game loop and low-level things to building a sidescrolling space shooter.

So if you’d like to learn how to make your own 2D game engine, read on.

Why reinvent the wheel?

Why would you want to make your own game engine?  This confronts a post I saw on this blog from last semester, which states that you shouldn’t reinvent the wheel: you shouldn’t spend time making something from scratch if someone else has already made it.

In computer science, that’s not always the best advice.

Yes, maybe someone else has already done it; but what if someone else did it better?  What if someone else made it, but more tailored for a purpose specific to something they were working on?  What if someone took something and figured out how to make it simpler, more accessible, or more efficient for a particular need?

There are plenty of game development platforms and engines that one can choose from: Unity, Box2D, Flash, DirectX, Microsoft XNA Framework, and so on.  Most of these are pretty powerful and can be used in many different kinds of games.  In some cases, however, they can be too powerful and are much more than what is needed.  Do you need an engine capable of 3D modeling and particle systems to make a Flappy Bird clone?  No.

Building your own game engine from scratch may sound like a daunting task.  It is.  It’s daunting, time-consuming, and a lot of work, but if you’re in control of developing it, you can decide exactly how it works and what you can do with it.  If you want to tailor it to a specific genre, you can do that too.  You can add things to your engine that are directly related to racing games, or shooting games, or whatever.  Plus, building something on your own from scratch is a great way to gain valuable knowledge about what’s really happening behind the scenes.

What to expect

In this ten post series, I’ll describe how to create a basic 2D game engine similar to the one I’ve been developing over the last couple years.  It’ll cover the basics first: rendering system (drawing things to the screen), the game loop, handling player input, and other important things.  Then it’ll cover some more graphics topics like frame-based animation and rotation.  Finally, in the last post, we’ll bring it all together and develop a full game.

This series assumes that you have at least some programming experience and some knowledge of object-oriented programming, although as both are prerequisites for the course itself hopefully that isn’t an issue.  Since not everyone in the class is a computer science major, I’ll be doing this series using Microsoft Visual Basic as the programming language.  It’s a fairly easy-to-understand language, it’s the one that I developed my game engine in, and it’s the one I’m most comfortable with: I know it like the back of my hand.  For posts that discuss developing an example project, I’ll attach the Visual Basic source code and compiled executable to the end of that post.  I’ve also recently ported my game engine framework over to Java and I considered writing this series using Java, but it was kind of a pain to deal with the way Java makes you do things and idk Visual Basic is just easier to explain okay.

Microsoft provides free Express Editions of Visual Studio on their website, and apparently recently they’ve also started offering the Community Edition of Visual Studio (which is pretty much identical to the Professional version I got through DreamSpark) for free, if you’d like to follow along with the coding adventure.  Did I mention it’s free?

Microsoft Visual Basic 2013 Express Edition: https://www.visualstudio.com/en-us/products/visual-studio-express-vs.aspx (make sure you download the Windows Desktop one!)
Microsoft Visual Studio 2013 Community Edition: https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx

[I’ve never really blogged before, much less written anything public about programming. If there’s anything you think is unclear about how I write, discuss, and explain code and the overall development process, please let me know and I’ll try to make things clearer in future posts!  Most of them are already written by the time you read this so let me know early on and I can revise things if needed!  Also feel free to ask questions 🙂 ]

 

This entry was posted in Game Designers and Developers. Bookmark the permalink.

4 Responses to So you want to make a game engine? Part 1 – Intro

  1. Bart Pursel says:

    Good write-up, Jace. Developing a game engine is challenging, but some of the reasons here illustrate why we (ETS at Penn State) developed our engine called FLAG:

    http://www.flaggameengine.com/

    Our primary programmer was spending a lot of time doing custom flash development for a variety of games for different courses, from Economics classes to health and human development. As it turns out, a lot of professors want similar things in their educational games: a way to simulate some aspects of a complex system. So when HTML 5 came out, our developer saw an opportunity to spend a lot of time up front creating an engine to make this somwhat sims-style games, that will help us be more efficient in future game projects. So far, so good.

  2. jqb5404 says:

    Hey, thanks for reading! You both bring up valid points about the “reinventing the wheel” argument I made, that sometimes it is easier to use a pre-existing game engine than developing one from scratch, which is true. One of the issues though is there can be a lot of overhead with engines that handle everything, and you may not actually need all of it. Some of it you may not need, and if you want to keep the size of the game small, this can be an issue if it has to be bundled with a larger engine. For example: Angry Birds doesn’t need anything related to 3D graphics, so it wouldn’t make sense to package that with the game.

    Perhaps “better” wasn’t the right choice of word: I’m not claiming the engine discussed in this series of tutorials to be “better” than a pre-existing engine because it is certainly not. But it’s also interesting to look at the inner working of how they actually work, and to consider some of the things an engine needs to be able to do. This is simply my approach on developing one and I do hope it’s beneficial to anyone who is interesting in developing a 2D game purely from scratch with nothing provided to them, and to those who want to learn some topics in game development that aren’t directly related to the construction of any game in particular. Perhaps a better phrasing would be a minimal game engine that provides just enough to write a 2D game with. I agree this is more of a topic for those interested in computer science as well, as two big things in CS and software development is writing code that is both efficient for its purpose and only includes what is necessary (but I also feel that it came across that way moreso since I’m a CMPSC major writing from that perspective).

  3. Paul Pham says:

    I feel like most people would not want to create their own game engine. They want to use preexisting engines that already exist because it would just save time and money. Since they engine itself already exist there will be a bunch of forums to go to get help if needed. But I do see the benefits of building and developing your own game engine; you can tailor the engine to the needs of the game. Which is definitely a plus; also since you created the engine you know the ins and outs of how its works and can always modify it when needed. A lot of developing teams what a game engine that is already in place because they might not have interest in what is happening in the backend. Then again, languages like C and Java came about with this mindset of making a new language because they thought they could do it better. Look at C and Java now; they are still being used in the computer science world today. But a lot of the game engines that are already out have been out for a while and are always improving their engines. How will you personally make something better then what is already out? I am just curious of how will approach this.

  4. Ryan Yosua says:

    To comment on the re-inventing the wheel argument, I really think it boils down to what people are trying to accomplish by making their game. If learning about low level game design or how to apply computer science to games is the goal, then creating an engine from scratch seems like a great idea. If the goal is to sell the game, or to create a game for class in a few weeks, I think using an existing engine is a better idea, unless the game requires some kind of feature that isn’t available in an existing engine. Personally, I am more of interested in the design, higher level programming, and the business aspects of creating games, but am looking forward to reading your series. I am sure it will be helpful to learn more about the inner workings of game engines.

Leave a Reply