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.

I want to download the source code of an Open Source game, so I can get familiar with game architecture. Does any one know of a game with source code that's legible, and easily understandable?

Edit: After some thinking, I'd like to make a game that can be played on the desktop or an Andriod phone with 2D graphics.

share|improve this question
7  
Most games that are open source are large, old projects that aren't always easily understandable, commercial projects that were open sourced for various reasons, or unfinished games that aren't really in a playable state. Plus, architecture a bit on type of game and language used. What sort of game do you want to learn from, and what languages do you know? (tutorials honestly might be a better option here) –  thedaian Sep 23 '11 at 19:38
    
@thedaian I know java, C++, C, javascript, and python –  jumpnett Sep 23 '11 at 20:07
2  
Possible duplicate: gamedev.stackexchange.com/questions/1497/… –  Tetrad Sep 23 '11 at 20:22
    
I agree with thedaian, at least that worked better for me. There are plenty of very good articles and books and tutorials out there. You will have to take time to pick the right ones but it saves you time later because you will already know why they code as they do and be able to recognize quality of the sources (which often smells). If you want portability, I would go for C/C++, but for those platforms you may do fine with Java. –  Pablo Ariel Sep 24 '11 at 9:00
    
Community wiki? –  Jari Komppa Sep 25 '11 at 5:22

9 Answers 9

I'm not sure what type of game you are asking for but there is an opensource game named OpenTTD written in c++. I think you could use it as a good sample.

some features that make this game unique:

  • It's an strategy game.
  • It has multiplayer support over internet and local network.
  • It supports translation to other languages through configuration file (which is generated in from raw text files)
  • It is compiled on almost every platform I know.
  • Its project is still alive!
  • It has built-in AI support.
  • Graphical and Musical data are completely customizable through patches.
  • It supports scripting languages to develop custom AI. so you can also read other AI written for this game.
  • It's relatively large project while it's easy to read and understand it's code.
  • It's based on SDL, and from that point they developed everything from scratch.

--Edit--

Just today I've started reading their code from the beginning. To understand what they've written you have to be a decent C and C++ programmer (although their code is well commented)! I mean you have to be a master of both languages since they are using structures from both! so if you are not confident enough about your programming skills don't even go near that code! that's the dirtiest code I've ever seen! (and I'm a dirty coder myself but they are something else!)

I think now I can suggest you check supertux code. it's a platformer game (just like super mario) and so far their code seems really clean (I've checked milestone 1.3). they have some comments in that code but only for places that you might get confused.

share|improve this answer
    
While OpenTTD is an awesome game, I don't think it's a good learning project. Most of it was reverse engineered from assembly, and there's still sections of code that reflect that. Plus, it's simply a huge project, and is probably too much for a beginning "learn game architecture" project. –  thedaian Sep 23 '11 at 19:33
    
@thedaian you may say so but every now and then that I need to do something new I just read what's written in their code. so far I think it's most readable opensource game out there worth reading! –  Ali.S Sep 23 '11 at 20:12
    
also I'm not sure when was the last time you checked their code but they've cleaned it since version 1.0.0 –  Ali.S Sep 23 '11 at 20:20

There's mainstays like Quake 3 or if you want something a bit simpler (and in 2D) look at the indie game Gish. They both use OpenGL and are cross-platform too.

Gish is a little on the messy side, though.

share|improve this answer

I recommend you first narrow your focus about what type of game architecture you are interested in learning about-- 3d pipeline, physics, AI, etc.

With a generic request for a good example of game programming, I think space invaders gl is hard to beat since it has clean code and open gl game play and interface while keeping things fairly simple.

cheers

share|improve this answer
    
Is space invaders gl windows only? I currently don't have windows installed on my pc. Not that I don't have access to it, just that it's not as convenient. –  jumpnett Sep 23 '11 at 20:20

Even though reading code can be useful, if you're a beginner in the domain, you won't learn anything. Especially if you look at the code of big projects like Q3A or OpenTTD. Those were made by an entire team, with each person having different coding practices, different ideas on how to make things. You'll only get the big picture, not the small details that make everything stick together.

Develop, fail, try again until you find something that seems to be good, fail again, rinse and repeat until you have something good. Different developers means different ideas on how to implement stuff. Just because it has been coded by Carmack/Any famous developer that has made a good game doesn't mean it's the best thing since sliced bread, and a different implementation might be clearer and faster.

share|improve this answer

I think one of the most important things you can do is choose a game that you enjoy playing. This will help keep you interested in it and will make you more familiar with how the code itself translates into the players perspective.

Once you've picked that game, regardless of how big it is, you don't have to try to figure out how every line of code works. Pick a piece of it and look at that. For example, try to figure out how player data is stored or how a menu item is drawn, etc.

The next thing you can do, which goes along with my previous bit, is try to change something. Not something huge (at first), just something simple and noticeable in game. Even something as simple as the text on a button on a menu or adding a menu item or changing damage calculations. Maybe you think they should have done something differently, try to change it yourself.

When I first got interested in developing games, I was really into 2D online RPGs. So I found the source for one online and I started building onto it. Adding my own features and tweaking things, fixing bugs, etc. That was in VB6 a few years ago and now I'm using C# and XNA and writing my own game from scratch. Because I enjoyed the games, it motivated me to want to work on it, to make it better. Coincidentally, this is also how I learned a lot of the programming, debugging and problem-solving techniques I use today in my non-gamedev related day job.

It's also very helpful if the game has a community of modders that you can ask questions and get help and examples from. But then again, even if that doesn't exist, you're already here and we're ready to help.

share|improve this answer

I think perhaps a good approach is to pick a game that you like and check out any open source games like that. The Open source game clones list could possibly help with the last step, a lot.

share|improve this answer

The stand out open source Android 2D platform game is Replica Island.

The source is on Google Code and the development was chronicled in the author's dev blog.

Here's a list of 15 open source games for Android which could also be useful to look at.

share|improve this answer
    
cool, I'll have to check those out. –  jumpnett Sep 30 '11 at 17:03

Have a look at penumbra. It looks like a great place to learn from.

share|improve this answer
1  
{citation needed} –  Lohoris Sep 24 '11 at 10:15

The Scrolling Game Development Kit 2 allows you to actually create 2D games and play them using a GUI without writing code. But it also allows you to see and edit the code that is embedded in the project that represents the framework/engine behind the game. Most of the code is exposed via the GUI, although a small portion of it is generated code based on where you place sprites and what maps you create. However even this code is visible if you generate the project and then open the resulting files in Visual C# Express. The entire program (IDE) itself is also open source. It's build on the OpenTK library (which it uses for interfacing with OpenGL from C#), which is also open source.

share|improve this answer
    
I'll take a look at it, but I am a programmer, so writing code isn't a big deal. –  jumpnett Sep 30 '11 at 17:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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