(02-10-2013, 04:19 AM)Hoeloe Wrote: Sorry, my post wasn't worded very well. I'm aware that complex programs, including games, can be made in C alone. It is a Turing Complete language after all. I was trying to get across that C++ is much more suited to this kind of development, as OOP and games go very nicely hand-in-hand. I'm aware you can do something similar in C with structs and pointers, but it's at a much lower level of abstraction, and only serves to confuse the issue (as well as running the risk of your implementation being less efficient).
The issue would arise when the aspirations of the game come into question. If it's a fairly straight forward game like snake or pacman; whether you code it in C or C++ the results are going to be exactly the same, and the code will probably be too.
Now, I will agree that making a game even as 'simple' as a platformer will be much easier in C++. Instancing is something that comes almost second nature to classes and to bigger more ambitious games. You want to focus on 'when' objects get destroyed not 'how' to destroy them. Think more about the games logic than having to manage memory and pointers. That is the reason I think people recommend C++ over C for game development; memory is managed real nice like. Instead of using a
Code:
struct game_obj *player = malloc(sizeof(struct game_obj));
Code:
free(player);
player = NULL; //you better make sure player isn't pointing to an object that doesn't exist in RAM
you can simply say
Code:
class game_obj player();
Code:
~player();
Hoeloe is right about C++ but there are going to be moments when you can only use C. For example, homebrew on obsolete consoles. Most cross compilers only offer C. You are going to have to manage your objects the good ol' fashion way.
I'm a sucker for low level hardware interfacing though; pointers turn me on. That feeling of knowing at any time you could have a memory leak or a pointer pointing to dangerous memory locations; imminent crash makes me moist.