doctor insidious blog header photo
doctor insidious's c-blog
Posts 0Blogs 23Following 0Followers 10



Designing a Game Engine: A quick, condensed guide

Preface: I would say I'm good at programming. Well, no, decent really. I'm only a freshman in high school, you see, but I still am quite good (In my opinion). Well, good enough to want to get better that is. Recently, my quest for becoming a computer scientist has shown me a C library called Guile, a GNU interpreter for programs. I had an idea, and decided to share it with you. By the way, I was going to work on that game I told you all about, but nobody really cared so I had no justification to do so. Any way, lets begin: (Also if you don't want to go through the trouble of actually learning to program, but still want to use this, wait a few months and I'll have made it probably)

What is a game engine?
Most of you are reading this probably because you want to make a video game, and you've been to a few sites and have seen the term "Game Engine" thrown around. Well, what exactly is a game engine, and how do I make it? It's really simple. Wikipedia.com defines a game engine as: A software system designed for the creation and development of video games. That is pretty much it. The beauty of a game engine lies in that when you have one, you don't need to mess around with opengl, frame buffers, and most importantly, pointers. God I hate segfualts. Any way, a good analogy for a game engine is that the game engine is the CPU and the operating system system is the game. The game runs off of the game engine. How do you make one of these things you ask? Well, It requires low-level programming, and the high-level programming. You might be better just purchasing one online ( http://www.garagegames.com, http://www.unity3d.com), however these tend to be REALLY expensive, as they are not focused on indy devs. There are some free ones out there, specifically http://www.blender3d.com, which is both a 3D modeler, but as well a game engine which runs python, one of the easiest programming languages to learn.

I lost you at high/low-level programming. What is that?
High/low-level programming only refers to the amount of abstraction between the programming language used and machine language. That may seem a bit confusing, let me explain: Low-level (C, assembly) programming languages run faster, but the code for something simple (for this example, the Fibonacci sequence) ends up looking like this (assembly program):

mov edx, [esp+8]
cmp edx, 0
ja @f
mov eax, 0

cmp edx, 2
ja @f
mov eax, 1

push ebx
mov ebx, 1
mov ecx, 1

lea eax, [ebx+ecx]
cmp edx, 3
jbe @f
mov ebx, ecx
mov ecx, eax
dec edx
jmp @b

pop ebx

It would be pretty much Impossible to write an engine this way. In contrast, Higher-level (python, scheme) programming languages substitute speed for clarity (scheme program):

(define (fib n)
(if (< n 2)
(+ (fib (- n 1)) (fib (- n 2)))))

Although you probably don't know what this is either, unless you went to MIT with the intent to get a degree in computer science, or actually have a degree in computer science, but you can tell that its a lot simpler.

The right tool for the right job:
Let me ask you a question: what would be better for writing a game engine with a game, a lower level or higher level language? The answer is neither: you use both: For writing the actual language itself, I would HIGHLY suggest C. It's low level, not completely crazy when it comes to syntax, has good graphics library support, and will help you improve your programming skills in general. For the language the games are written in (and then interpreted by the engine), I would use scheme. There is a great GNU library out there called Guile, as mentioned earlier, that would save you the hassle of writing your own interpreter. Also, scheme is good for learning the basics of recursive and iterative programming, a key part of programming.

Graphics library waaaaahhhh?
A graphics library is what you would use for drawing stuff on the screen, making GUI, and the like. The two main libraries are: openGL and DirectX. While both equally as powerful, openGL is cross platform, however it is lacking in anything besides graphic tools (I think). DirectX, while only available for windows, provides a suite of tools, and in fact, MS Vista's desktop was actually written in direct 3D, the DirectX 3D library, and that is why I use Kubuntu now among other things. Both openGL and DirectX are viable options, but since you probably want you game engine to be cross platform, you probably shouldn't use either. Yes, openGL is cross platform, but I'm pretty sure you need to tweek the code quite a bit. I suggest SDL (Simple DirectMedia Layer), a cross platform library available for: SDL supports Linux, Windows, Windows CE, BeOS, MacOS, Mac OS X, FreeBSD, NetBSD, OpenBSD, BSD/OS, Solaris, IRIX, and QNX. The code contains support for AmigaOS, Dreamcast, Atari, AIX, OSF/Tru64, RISC OS, SymbianOS, and OS/2, but these are not officially supported (taken from www.libsdl.com). It's not an actual graphics library, but instead a tool set that provides easy cross platform compiling and has a large tool set for things such as controller input.

Well, that's all for now young folk, I hope you enjoyed my commentary. By the way; IF YOU STEAL MY IDEA FOR A GAME ENGINE THAT USES GUILE, I'LL HURT PEOPLE. Oh, one last word of advice, when learning to code for Linux, USE EMACS RAAAAAHHHH.

End part one.
Login to vote this up!



Please login (or) make a quick account (free)
to view and post comments.

 Login with Twitter

 Login with Dtoid

Three day old threads are only visible to verified humans - this helps our small community management team stay on top of spam

Sorry for the extra step!


About doctor insidiousone of us since 5:40 PM on 02.16.2009

Hi, my name is Matt, but you can call me doctor insidious, because that is much more awesome.
My top ten games:
9. Sam and Max
8. Gears 2
7. Tap Tap Revenge
6. We <3 Katamari
5. Castle Crashers
4. Persona 3
3. Braid
2. Crayon Physics
1. Cave Story

I am one of the few people who actually know how to program in this world. And by program I mean know how to use pointers.

#include <stdio.h>

#define COCKS 0

int main (int argc, char **argv)
printf("Hi I'm doctor insidious\n"
"This is the most useless program I have ever seen\n");
return COCKS;