Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Possible Duplicate:
Where can I find good (well organized) examples of game code?

I have coded several C++ games and now I'm building my own game engine and editor.

I have some doubts about the design and I wish to find great examples to follow.

What is the best designed in your opinion?

Must be object oriented. Programming language does not matter, but I prefer in this order: C++, C#, Java or another similar.

EDITED: To clarify more, I'm not interested on game-specific code. I want general purpose game engines.

EDITED: This article explains what is a game engine: game engine at wikipedia and here is a list of known game engines: list of game engines at wikipedia

share|improve this question
Do you actually understand my question? I wish game engines (not just games). And I requested Must be object oriented. In the thread that you said, the answers are for games only (Doom3, Prototype, etc.) And also there is a graphic toolkit (OpenSceneGraph) but there is nothing specific about "game engines" on that thread... You can close or delete my question if you don't like it, but I don't understand the down vote... :( My question is not the same –  Dani Nov 7 '10 at 17:51
To clarify even more, I'm not interested on game-specific code. I want general purpose game engines. –  Dani Nov 7 '10 at 18:01
There is a difference: Not all games run over a general purpose engine. Doom3 has a FPS specific engine, Prototype is different, and so on... May be they have things in common (resource management, scripting...) but this is not relevant to my question. My question starts with the phrase "I have coded several C++ games". I reiterate: My need is to find a good general purpose game engine source code. Not a game source to search for reusable code. –  Dani Nov 7 '10 at 23:28
Doom 3 has an "FPS specific engine" but also has all the parts a generic engine needs - as you say, resource management and scripting, 3D rendering, physics, and so on. It's a generic engine and more, not somehow less. –  user744 Nov 8 '10 at 10:17
@Joe Wreschnig I'm inclined to agree with @Dani on this topic. Although all games are powered by some form of an engine, the architectural patterns used for a "one-off" engine and an engine designed to work on multiple titles are quite different, even if they both have scripting, resource management, 3D rendering, etc. components. Additionally, looking at the code for a game built on an engine developed by the same studio is probably not the wisest choice, as it will not give you a true indication of how flexible and easy to use the engine is in a 3rd party environment. –  Ari Patrick Nov 8 '10 at 19:20
show 9 more comments

closed as not constructive by Tetrad Mar 21 '13 at 20:56

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

5 Answers

up vote 5 down vote accepted

I think the best way to go about building a game engine is to start with what you already know pretty well and add those features that are tedious or repetitive.

For example, I do a lot with Python / pygame (which is an SDL wrapper) I enjoy the system quite a bit, but there were three things that bothered me:

  • Building the animation loop is tedious, and they're all pretty much the same.
  • The basic sprite object is very limited. I wanted an improved sprite with direction and speed, ability to handle various screen edge conditions, multiple images, and multiple collision schemes.
  • Pygame has no UI features. I wanted simple labels, buttons and a number chooser I
    could easily add to my games.

It was relatively easy to create an object-oriented wrapper around these features. Take a look at chapter 10 and the Game Engine documentation available here: http://aharrisbooks.net/pythonGame/

(This was written as part of a book, but you're welcome to the game engine even if you don't want the book.)

Chapter 10 explains the motivation and techniques for building a basic 2D game engine. You might enjoy it as you build your own. The actual language is not that important (except of course you'll need an OOP language to support OOP.) If you're already using SDL with C++, you might begin by adapting my engine to C++ / SDL.

share|improve this answer
add comment

The venerable Quake (ID tech) engine design has withstood the test of time and is probably the most successful game engine design of all time. Everything besides the renderer has been largely unchanged since the late mid 90s and is still used in modern games like ETQW.

Full source code for four iterations of this engine (Quake 1 through 3, plus Wolf ET) is available under the GPL. There are probably over a hundred actively-developed community-supported Quake-based game engines which are keeping them relevant in the modern age. Especially worth a look is XreaL for its fantastic renderer and ioQuake3 for its faithful maintenance of Quake 3 optimized for modern hardware. Also, for more-recent "official" ID versions of the engine, the game logic (not the whole engine) is available as well.

Even if you don't end up using this game engine, it's worthy of study for its well-thought-out client-server separation architecture and segregation of game logic from low-level details.

share|improve this answer
I wouldn't exactly call pre-Doom3 id tech object oriented, though. –  Tetrad Nov 8 '10 at 16:46
Nope, not object-oriented, but as I said, it's worthy of study. I mean c'mon, just because it's procedural doesn't mean it will give you eye cancer if you look at it! ;) –  Max E. Nov 8 '10 at 17:41
add comment

The Ogre3D rendering library is pretty close to engine code and from all accounts I've heard is very well designed and very OO.


share|improve this answer
+1 Great engine. Thanks Tetrad! I already know it, but I never used nor seen it's source code. Do you know whether it has integrated AI (ie. Path finding, etc.) –  Dani Nov 8 '10 at 22:02
I think it's all just rendering related. –  Tetrad Nov 8 '10 at 23:20
Ogre is a graphics rendering library only. Object-Oriented Graphics Rendering Engine. –  Jonathan Sternberg Nov 10 '10 at 3:38
add comment

When talking about game engine, I guess you are thinking about anything that is not the render engine, sound engine, physics engine, input engine, etc.

So you might be thinking about game architecture, AI, or design pattern/systems etc, which are used to structurate a software into managing data and other components to create some sort of scene/thater/illusion, thus producing a manageable sets of rules to tweak to create an actual "video game".

This is the actual top layer of a video game, and I even tried to learn a little about it, it's vast, complicated and requires a lot of knowledge into all other subjects. Imagine you want to recreate a alternate reality from nothing, keet track of and computing every each event, and regenerate accurate data from those, at whatever moment: for every kind of game there is some kind of subset game-engine, and I don't think it's actually possible to make a generic engine which is mathematically fast enough. Even for a game where you control a single character, there are still a lot of things which can vary and can still require the game to change the whole architecture.

The gaming industry is not as well-served by open-source as other fields of computer sciences, just because entertainment has different kinds of license types, which involve artistic licenses: game product is only paid by a customer, and AFAIK, there is only few engines that seems good enough to work for you : Hord3d, NeoAxis, blendelf, Panda3D. But I can't assure you they will be as much easy to use as tools like Unity, Torque, C4 and others; keep in mind that a game engine is, with the graphical renderer, I think the most difficult type of software you'll find in game-making.

share|improve this answer
add comment

For me using Python with Pygame is a good solution. Maybe Python is a bit slow but for today's computers and if you just try to optimize your game this doesn't matter. Pygame has a very good documentation at the original pygame's site. But first take the beginning of a tutorial to learn some basics. For speed optimisation (converting images,...) you will need other examples which are easily to find.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.