Looking for 'professional' indie game-code to read.

I am an intermediate Java programmer, and a beginner game developer. I created a number of simple games, with simple AI and game mechanics.

I’m looking for some source code to read, in order to get a feel of what more ‘professional’ source code looks like, and what more ‘professional’ game and application structure looks like.

The code should be:

A) Understandable. Nothing that is too hard to follow.

B) “Common”. I want the code to use common ideas and practices, nothing “revolutionary”, because I want to get a feel of what game code ‘commonly looks like’.

C) Doesn’t rely too much on a library or engine that I don’t know. Basically currently I’m only familiar with Java2D and Swing. The code of course can be using different libraries (and most probably would), but I don’t want it to rely too much on the specific library, so I’ll be able to understand it.

D) Preferably 2D game.

E) Not too big and not too small.

I want it to be a good ‘first introduction’ to some ‘professional’ indie code, so I’ll get a feel of what it looks like, and how the game and app are structured.

Thanks

Not a lot of big indie developers tend to release code, especially if it as original game.

However, there is the super jumper, open source game made by the creator of LibGDX:

Source

Or, if you want to see something truly “amazing”, download minecraft and decompile it using the forge thing. However to my understanding, a lot of minecraft is still old code and terribly written but look into some of the new stuff, recently changed stuff. Check out the forums for that info, I think recently it was audio/sounds and how it was loaded.

However, do this at your own discretion, I am pretty certain that developers do not appreciate others ripping their games down and checking out the code…but in the name of learning, those people can go fuck themselves.

But luckily we have people like princec! ;D

http://www.puppygames.net/blog/?p=914

Thanks both of you :slight_smile: Which one of the two games you mentioned better suits what I asked? (Be understandable, ‘common’, doesn’t rely too much on some library, etc).

The link by nsigma, that game is legit. Even so, both would be fine to look at for the simple fact both games are very well polished and Super doodle jump is actually on android and is literally a famous game. Here in Scotland when you go to arcades, they have a super jumper machine, just for that game.

Just as a side note, indie developers are not automatically better coders! I don’t know if that’s what you think, but some developers can write absolutely crappy code and still become famous because the player only cares about the end result, not the code! You also should develop your own code style instead of copying someone else’s, believee its a really good idea to do it early on! Although there are conventions and some basic structures most programmers follow, it doesn’t mean you can’t branch out and do something different, most everyone does it!

Good luck :slight_smile:

Don’t even bother with this. This breaks points a, b, d, and e in the op. Plus, Minecraft code != amazing.

@Reffering to your point c, there are very few games in comparison that use Java2D. I would recommend learning an OpenGL based wrapper/library/engine. LWJGL, JogAmp, Libgdx, and JME are all good examples of this. There are example games on the wikis of these respective projects along with some nice tutorials that can help you out.

Hence why I quoted amazing, sarcasm is hard to imitate over a keyboard.

Minecraft code is terrible, however terrible code does not mean terrible game. That was why I mentioned it.

Why is minecraft code bad now?

@OP I think you’ll get further learning from specific tutorials rather than full games. Obviously full games are a lot of source code, and it’ll take longer to understand that than if you have a tutorial of some sort. Also, game and app structure are really dependent on the game sometimes, so the same structure for your game may not be optimal. I’m not saying not to look at these game source codes, but don’t rely on it as your main learning source.

Most “professional” stuff is terribly coded. Revenge of the Titans especially so, and I bet Minecraft is abysmal too. The reason is because we are focused on actually finishing something than doing fancy engineering and making things pretty, readable, or understandable beyond getting the product out there.

Cas :slight_smile:

What you’re saying is interesting. Let me see if I get something.

The reason why people work hard and study hard to learn how to code clean, readable and maintainable code, is because at the end, it’s supposed to increase your chances of creating software with few bugs. The idea is that clean readable code means better chance for good software (of course, that’s only part of it). It will be easier to maintain, debug, and code further.

And you’re saying that “most ‘professional’ stuff is terribly coded”, and that’s because “we are focused on actually creating something rather than doing fancy engineering”, etc.

This means that clean code doesn’t help with creating good software.
Am I understanding correctly?

Different situations, at least somewhat.

In enterprise programming, clean, easily-maintainable code is important because it will likely need to be maintained for a long time (years, maybe decades), and many people will be working on it, so you can’t write everything in that horrible weird way that only you can understand.

In gamedev (especially indie), the maintenance aspect is greatly reduced (although some parts are long-lasting, e.g. core engine to be used for multiple games, multiplayer servers, etc. These are also often supplied as a 3rd party library for these exact reasons), eventually you will simply move on the the next game, yes you might be pushing updates, but it’s not going to be (well hopefully not) a complete overhaul or product revision. Also there are fewer people that need to work on it, and they are usually tighter-knit. (Again, this goes especially for indie development)

Gamedev is heavily effected by deadlines, enterprise by maintainability over many product iterations. Respective codebases tend to reflect that.

[quote]This means that clean code doesn’t help with creating good software.
[/quote]
You have to define “good software.” It may be good because it’s cleanly coded, or it may be good because you got it released on time. Ideally, it would be good because you did both.

We learned it like this. In a perfect world with an unlimited amount of time and budget you can write perfect code. The thing is, both time and budget is limited. So you have to take shortcuts.

I’ve worked with people that were geniouses in their field, but they never managed to complete a project on budget, because something in the code was always badly engineered (even though it was working completely ok) and they had to fix it. A friend once got a week of work thrown out of source control, because our architect thought “It just doesn’t feel right”, without having any specific reason why.

It makes me cringe a little to not go the clean way, but sometimes you have to sacrifice clean code for getting a project done. The problem is that most customers (or players in games) don’t really care how nice the code is. They just want that damn thing to run.

For the most part, I agree with the people in this thread.

Learning how to write professional code off of games, and seeing how others write code in games is going to vary by developer. What is worse is that you’ll not be seeing the best code available, at least professionally.

There is a few options, though, I’d suggest actually looking for games that are open source. Sometimes, they are forced to write code a bit more readable than other projects since, they are actually trying to get people to join their coding projects. Scouring open source repositories like Github and Sourceforge for gaming projects will give you a large pool of gaming code to look at. Especially if you are just looking for how people structure code overall.

The other way is just to code like they do in tutorials and demos. The Java tutorials has some of the best written code when it comes to how to organize Java in a readable way. If you want to learn how to write code in the most beautiful way possible, then just emulate the tutorials.

From my experience

It is double work. First, you have to make the code work… then you have to make it readable and organized. The shorter the code is, the better it runs. The more you make things readable, the bigger your overall program gets. It is just inefficient to make things 100% readable. I usually strike a balance between both. For modules, I usually have it slightly unreadable but I work in the readability by having descriptive comments. For stuff that other people have to read, I usually write variable names that tell people what things do, and separate the code into readable functions.

It is a style thing. When you begin to code games, you’ll realize that readable code will short circuit your productivity. You’ll fail to make your prototype, and you’ll learn. Game making requires a balance between rapid prototyping, and… more rapid prototyping.

There is a balance. We all start off with the best of intentions, and then… we need to get it finished.

Enterprise code is probably the worst for it. So elegantly over-engineered, usually, that most of the time nobody knows how it works anyway. But it can look quite pretty. It rarely works very well. Most of the worst code I’ve come across is from my days as an enterprise developer. I’m proud to say mine was some of it :slight_smile:

Cas :slight_smile:

Shameless self-promotion: There are a bunch of simple open-source games done in Swing and Java2D at Static Void Games!

Then don’t look at my source code ;D

I’m joking a bit of course, I like very long … variable names, you see what I mean.