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'm currently in the planning stage for my next game, and since I've been away from C++ for a while I have some questions about helpful libraries. I plan on making a 2D game with SDL, constructing my own simple 2D engine. I plan on making this game for the PC.

What libraries would you recommend to make this process easier?

What about unittests?

What about an enforce operator to throw exceptions?

int a = 1;
enforce(a == 2); //Throws an exception, 

Specifically, i'm looking for general purpose libraries, that implement that make my life easier (like boost). Also, a helpful library for physics/collision, AI, XML file parsing (specifically working with the Tiled map editor), and any others that you guys have used that are useful in a 2D game.

share|improve this question

closed as not constructive by Josh Petrie, Tetrad Mar 24 '12 at 23:22

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.

    
I thought that C ++ 11 had for each... –  jco Mar 24 '12 at 18:49
1  
You're right, my fault, it added the "range based for" that iterates over all elements in the list –  RedShft Mar 24 '12 at 18:52
1  
A terrible language feature, IMO. –  DeadMG Mar 24 '12 at 19:37
    
Why would you say that? –  RedShft Mar 24 '12 at 19:40
    
nevermind, 13 chars –  dreta Mar 24 '12 at 20:41
show 1 more comment

5 Answers 5

up vote 4 down vote accepted

Come up with a game first, see what you want and need. When you have specific problems, you can use google to solve most of them, for the remaining few there's gamedev.stackexchange.

I can suggest Box2D, because it's a great physics library, but what's that doing for you, you'll go "there's a 2D physics library, maybe i'll make a 2D game with physics in it"? That's the absolute wrong way of going about designing games.

I can suggest SFML for 2D graphics, but that's not right aswell. What if you want a game with complex visual effects or you want the ability to texture random polygons, you can't do that with SFML.

Pick your tools for the job, not the other way around.

share|improve this answer
    
Very wise advice, thanks. –  RedShft Mar 24 '12 at 21:11
add comment

boost::foreach works pretty much the way you want :)

Wikipedia has a nice list of C++ unit testing frameworks.

You could make your own enforce function pretty easily, something like this I suppose:

void enforce (bool expression)
{
    if (!expression) throw Exception(5);
}

where Exception would be a class defined by you. How you go from this to an enforce function that tells you more about what went wrong though, I'm not sure.

share|improve this answer
add comment

AI will be game specific. There are not a lot of general AI libraries, and even fewer designed for 2D problems.

Regarding other libraries, since you mentioned Boost, just use that.

For your "enforce" function, you need only a simple assert system. It takes only a few minutes to build your own. I would recommend against having it throw exceptions. Exceptions have a lot of problems, I'm fairly certain you're not at the level of writing exception safe code, and when it comes to debugging the exception model loses a lot of useful information. I have my assert macros log the failed test, the file/line/function, call __debugbreak(), and then abort. Much better for debugging than an exception ever will be. Of course only intended for programming errors and not errors of invalid user input, but the latter if better dealt with in other ways anyway.

Box2D is the popular choice for physics in 2D games.

Finally, for unit tests, you might check out Googles test library. Though again, writing your own simple version of that takes a matter of minutes if you have a decent proficiency in C++.

share|improve this answer
add comment

Simple OpenGL Image Library, devIL, and AssImp are some fairly nice content importers.

Configurable Math Library is a fairly nice linear algebra library, and I believe boost has one as well.

And finally, FreeType-GL is a text-drawing library that I haven't used, but should work fairly well

share|improve this answer
add comment

I have to second what @dreta said about coming up with the game first, and figuring out what you may need... That being said, since you're using SDL for 2D, obviously SDL has lots of libs that were made just for it to help you out. SDL_mixer, SDL_ttf, SDL_image are all obvious choices for basic tasks. Box2D, Torque 2D, ODE are all great choices for physics, ODE though it's recommended to be outdated and is technically no longer under construction officially, was used by the game World Of Goo. Which has incredible physics and I've not seen a single physics glitch in the three times I've beaten it (personally).

Regardless of whether your game is 2D/3D whatever, I've always been a sucker for a useful script engine. So Lua and Python would be my first choices any day. People say that Python is not good for an embedded or extension script engine for games, but I've used it personally and it's equivalent Lua codes worked actually slower than the Python. I've heard of people using JavaScript in games also, a big one to note is Wolfire's Overgrowth which uses JavaScript for interaction with the other world stuff.

As far as graphics go, it's well known, easy to set up, and perfectly acceptable to use OpenGL built into your SDL games, even for 2D graphics. One game to name that isn't released yet that we're expecting new videos on soon is the http://elysianshadows.com/ project which uses OpenGL accelerated SDL, for 2D.

For XML I stick with tinyXML almost all of the time, it's a great library and it works extremely fast with relatively minimal overhead. To me it just feels cleaner than other XML libraries.

PS: I didn't really get into the other stuff you mentioned, because it looks like everyone else provided great answers for those.

share|improve this answer
add comment

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