I used to work for a small video game company. When I started we were making AGB games (Game Boy Advance) and all of our programming was in C (a bit of perl for auto-generated code). When we started working on NDS (Nintendo DS) games we switched to C++. Overall I think C++ worked better for us for a number of reasons, but the for-most reason is simply that games are object oriented.
That said, it's not like we had any problems writing games in C. We still took an "object oriented" approach. It's important for me to clarify what I mean by object oriented however. Mostly this just meant encapsulation/grouping. A sprite would have a coordinate, a memory location in VRAM, etc. Inheritance in C++ was used, but sparingly and only when it made sense. Generally game programmers uses composition over inheritance. For example, a Player Entity can have either an ISA or HASA relationship with a sprite or 3D model depending on how you think about it and design it. In general it is preferable to use HASA relationships for everything as otherwise you end up with a ton of extra/useless code and complex, twisted diamond shaped inheritance graphs. Overall C++ lets you model game objects a little better (in my opinion) than C. That said, C is more than up to the task, and some of the greatest games have been written in C (pretty much everything by id software pre-Doom 4). Some of the best libraries are also written in C, like the two you mentioned: OpenGL and SDL. TL;DR - C++ makes some things nicer but you have to be careful because it can be tempting to add complexity. C is great for games. SDL is an excellent library to get started with, and has been used in some AAA titles (Unreal Tournament on Linux, for example). OpenGL is the standard for 3D on everything except WIndows/XBox. P.S. - If you are going to develop on Windows, XNA is pretty good. At this years Global Game Jam my team used C#/XNA. I went in with a very minimal understanding of C# and almost no XNA experience and managed to complete a 2D multiplayer game in 48 hours. Microsoft went through a lot of trouble to make things fairly obvious (although it still has its quirks). -Niki Yoshiuchi On Tue, Aug 10, 2010 at 2:43 AM, Jacob Todd <[email protected]> wrote: > On Mon, Aug 09, 2010 at 09:02:53PM -0500, Matthew Bauer wrote: > > What game libraries are suckless? (SDL, OpenGL) > > > > What programming language is best for games? (C, Python, or Go) > > > Just hack on the Quake source ftp://ftp.idsoftware.com/idstuff/source/ >
