API advice for game dev - new to c++

Hi all!

I'm new to C++ (and this forum! :)) but I'm hoping to use it to develop a game for eventual distribution on Steam - nothing fancy, a simple thing that might entertain a few folk and maybe put a couple of pennies towards the bills if I'm lucky.

I'm also hoping I wont have to write my own graphics engine, collision detection etc. and so.. anyone got any suggestions for good, free to use commercially and preferably easy to learn/ well documented APIs that no C++er should be without?

In particular I'm looking for;
- graphics (2d and/or 3d but I'll probably be using 2d - sprites or vectors)
- dealing with input devices (I want to implement local multiplayer with multiple USB gamepads, ideally with rumble for pads that have it)
- collision detection/ physics (all I really need is basic swept circle tests I think, but as long as it's simple more wouldn't hurt)
- particles (because who doesn't like prettyness?)

but also anything else that you particularly like or think might be helpful. :P

I've got a few ideas of where to start but.. there's just so many options... so yeah, any suggestions greatly appreciated!
Cheers,
OB :)

edit: oh, also preferably APIs that work on as wide a spectrum of systems as possible if that's applicable... I really don't know much on how it all works yet. >.<
Last edited on
I have a couple things you might not like:

- You will be writing EVERYTHING. Otherwise, you will write everything until you learn how to install third party libraries.

- wxWidgets is a good GUI library, but again, I even have trouble with trying to install it, and I'm nearly 3 years into practice.

- Input devices will need another library, unless you want to write your own classes and functions to handle them.

- API's aren't installed, they simply are. an API is an Application Programming Interface, that allows a programmer to call functions of another, running program. An example of this would be Windows Operating System (Windows has an API).

Disclaimer: I have not had lessons by any proffessors or professionals. I have taught myself C++ for 3 years now, and will be going into computer science 1 next semester.

Before you jump into graphics, drivers, and game engines, there are a couple things you WILL need to write C++:

Necessary:

- Compiler
- Text editor

Optional:

- IDE (integrated developement environment; it formats your code, highlights stuff, can allow you to bookmark, create projects, etc...)

- Any third party library
____________________________________________________________________

My recomendations:

Compiler: MinGW ( http://sourceforge.net/projects/mingwbuilds/files/mingw-builds-install/mingw-builds-install.exe/download ) (I believe...)

IDE: Code::Blocks ( http://www.codeblocks.org/ )or if you're up to it, I really really love NetBeans (C::B doesn't have bookmarking for lines)

3rd Party Libraries: Boost (a great one to have). I have been told wxWidgets is good, but I have not been able to get it running properly yet. PDcurses is a text-based 'graphics' and input library, if you are content with that.

I have Nuwen's Distro of MinGW, which can be found here: http://nuwen.net/mingw.html

That includes MinGW AND Boost, so you wont have to install Boost yourself.
Last edited on
I recommend SFML http://www.sfml-dev.org/ , it's a multimedia library but is very often used to make games. And IIRC it includes joystick classes that may work with game pads (I have no experience with them). I personally love SFML because it is easy to use, beautifully written, and c++.

There are other options like SDL http://www.libsdl.org/ and Allegro https://www.allegro.cc/ but they are C libs.

Edit: For physics, I've heard Box2d http://box2d.org/ and Bullet http://bulletphysics.org/wordpress/ are good, but I've never used either.
Last edited on
Hey, cheers for the information, IWishIKnew (seems an appropriate name, haha).

So is it libraries I should be looking into for all this rather than APIs by the sound of it? :s
Thus far I've only been researching to see if c++ is the way to go but looks like I might've got some things muddled up. :S

I'm planning on writing some simple programs and following through a bunch of tutorials to get me familiar with the basics in the next few days, I was going to use Notepad but I'll look into C::B and NetBeans for writing in, cheers for them. I'll look into MinGW for the compiler too, though as far as I can tell (I may be wrong >.<) it can't compile for Mac or Linux from Windows, I was hoping to compile for all three from my Vista laptop.

I've written collision detection scripts, physics engines, etc. before in Gamemaker's GML language just to get to understand them, but I was hoping for actual development there'd be something (libraries by the sound of it) available so I wouldn't have to reinvent the wheel as the saying goes. :s

In this case I think my question has changed to: Any suggestions on good libraries that are free to use for commercial purposes to do graphics/ input devices/ collision detection/ particles?

In fact, I might change the thread title if I can... Cheers again for the information, iWishIKnew :)

edit: Forgot to reply to the bit actually about libraries xD I'm going to need either sprite or vector graphics, possibly both so text only wont do it I'm afraid. Am I right in thinking Boost is a collection of libraries rather than a library itself? I'm not sure from their homepage. >.< I'm reading up on wxWidgets now.

edit2: Oops, didn't see your post naraku! I'll add all those to the list, thank you! (the list is getting pretty long now and it's too late to look them all up now. >.<) Is SFML a library or an API? I'm very confused between the two now... >.<
Last edited on
OK... so sfml-dev is a library which is joined to the rest of the code by it's API... is that right?

In any case, it not only supports gamepads - it supports up to 8 of them! Which I think is rather cool. :P It also doesn't look too complicated, so I think that I will be using it at least for the control pad part. Cheers, naraku!

I am still looking for more good libraries to use though if anyone has any suggestions - collision/physics (though I have 2 to look at already), graphics and particles being major ones. :)

edit: actually, it looks like SFML should be able to handle all the graphics too... I'm going to look some more after work tomorrow but I'm getting very excited about it now. Haha!
Last edited on
Because sfml was already mentioned.
How about SDL.
SDL itself is only 2D but its OpenGL compatible so you can also make 3D games with dynamic lightning and so on.
SDL Website:
http://www.libsdl.org/
OK... so sfml-dev is a library which is joined to the rest of the code by it's API... is that right?
Basically, but I wouldn't get too worried about terminology right now.

SFML can handle graphics, sound, networking and window management. It has pretty much everything you need to make a 2D game. For collision, there is a class available here https://github.com/LaurentGomila/SFML/wiki/Source%3A-Simple-Collision-Detection-for-SFML-2 I believe it was written for an earlier version of the library and may need tweaking to work, but it's a start.

There is also a book for SFML that came out recently http://www.amazon.com/SFML-Game-Development-Jan-Haller/dp/1849696845/ref=sr_1_1?ie=UTF8&qid=1377134627&sr=8-1&keywords=sfml I don't have it but am planning to get it since I've heard good things about it.

Edit:
As theblackdog said, SDL is also a good library for making games (I did mention it earlier), but use version 2.0 instead of 1.2
Last edited on
Ah brilliant, thanks theblackdog and naraku.
It looks like I've basically got a choice of SFML or SDL. I'm looking into both now, so far it looks like SFML may be better documented but SDL better featured. I'll have to read up on them more before I decide though.
If you'd recommend one other the other then I'd love to hear why but for now I'm going to mark this solved. :)

Thanks again,
OB :)
@oblongoidbanana

I would HIGHLY recommend practicing the basics of C++ before jumping into graphics and stuff. C++ is low-level. To give you an idea, a program I wrote to back up files is 3,000+ lines long. That mainly consists of the backup class I wrote, and the rest is menus, control functions, etc... My point is, C++ is nothing you can learn over the span of a week, or even a month. Game-maker does not use C++, and what you're used to is higher-level than C++. This means that you worked with pre-defined objects, whereas in C++, you will be working to create them from literally the ground up.

If you want to jump into it, go ahead.... I suppose...

Libraries:
On another note, libraries aren't APIs. Libraries provide functions that do different things, and you can find libraries that have functions which will allow you never to directly touch an API. An example of this is boost's filesystem library. I can get any file/folder on my computer without toughing Windows' nasty API.

Compiler:
You're right. You will have to download a compiler for each Operating System (and onto each operating system), and port your program over to each one. This means changing up all of the functions that interact with that operating system's API. Example: instead of using windows' API to copy a folder, or move a file, you would have to find the mac-equivilant functions to have it work on a mac.

About Graphics:
You will be creating objects for those, unless you are able to install 3rd party libraries, but writing out your own objects would provide you with a lot more flexability than using a pre-written object.

About Installing Libraries:
I don't want to be a stiff, but you might be running into this a bit too fast. I get the impresion you have never written C++ before, and are only on the basics. Just don't get too excited...
IWishIKnew wrote:
On another note, libraries aren't APIs. Libraries provide functions that do different things, and you can find libraries that have functions which will allow you never to directly touch an API. An example of this is boost's filesystem library. I can get any file/folder on my computer without toughing Windows' nasty API.
You are right libraries aren't APIs, but most libraries have an API (publicly exposed functions).

You will have to download a compiler for each Operating System (and onto each operating system), and port your program over to each one.
Not necessarily, GCC (and probably others) can cross compile.

This means changing up all of the functions that interact with that operating system's API. Example: instead of using windows' API to copy a folder, or move a file, you would have to find the mac-equivilant functions to have it work on a mac.
Or use cross platform solutions like boost.

You will be creating objects for those, unless you are able to install 3rd party libraries, but writing out your own objects would provide you with a lot more flexability than using a pre-written object.
I have no idea what you mean here, can you elaborate?

There is no reason oblongoidbanana can't learn c++ and game programming simultaneously if that's how he/she want to do it.
Hey IWishIKnew, thanks for the reality and cautionary reasoning. You are of course right, there's a lot I intend to research before I start making anything, but that's why I'm here. Haha. I know GM isn't quite the same but hopefully some of the more advanced stuff I did in it will come in handy, I never had to worry about the really low level stuff but that's just something new to learn. :)
If it does turn out to be too much right now I'll take an intermediate step, maybe Java or something, but for now I'm going to try it, take on what you've said and see what happens. :P

naraku - thanks for the confidence boost! haha. And the solutions to those problems. I think GCC is for Linux only (in the downloads the windows option is MinGW which IWishIKnew already gave me the download for), do you know if there's a windows solution that can cross compile? I don't really need it just yet so I can research that further along, but it'd be good to know if you know of one already. :P
About the libraries -
The main three are indeed SFML, SDL, and Allegro. There are more but that's left to googling.

SFML is really easy to use and provides good performance

SDL is a bit harder but there are few things you get only with it.
a. Lower level control
b. You can use it to work on legacy consoles, i.e Gyrovorbis actually can run there in-development game on Sega Dreamcast.

I haven't worked much with Allegro but I found it pretty smooth to use. One thing that really appeals to me about Allegro is it can run a lot of devices.
Ah cool, thanks for the information, Austin!

Sounds to me then that SFML is probably my best bet as I'm starting out and only need Windows, Mac and hopefully Linux support (which I'm happy about as I thought it seemed very well documented - though making stuff for Dreamcast would be ~really~ cool! :P). I will have a look into Allegro too though, in future maybe being able to target phones and the like could be a good next step, so I'll give it its fair shot if it makes that easier/possible. :)

Thanks again to all of you who've helped me too. This is my first thread here but I'm already really blown away by the generosity of you guys, says really good things about the community here. :)
Last edited on
Kudos on wanting to start game development, that was my primary motivation to get into programming as well :) I'd also recommend SFML, and I find Box2D to be really quite simple to get going, allthough I haven't tried bullet or newton. Good luck :)
You may also want to take a look at Thor http://www.bromeon.ch/libraries/thor/ it is an extension to SFML and looks like it has a particle system.
Haha, fafner - I wouldn't be at all surprised if making games was most programmers reason to start. Either that, the film Hackers or mobile apps I suppose. ;p

For now I've installed code::blocks and MinGW got a 'myfirstproject' started that doesn't really do a whole lot (at all xD) but uses Boost and SFML to not do that whole lot and compiles fine... so I'm happy with it at the moment. As soon as I get some free time I'm going to look at getting a simple game loop going at a set loops per second, then maybe make it actually do something ;)

After that I will look into more libs as I need them, Box2D and Thor (cheers for that one naraku, looks like it could streamline/enhance a fair chunk of SFML :o) do both look intriguing though so I'll be sure to get to them sometime. :)

Cheers,
OB

Also, fafner - luck much appreciated, ta ;)
Last edited on
naraku wrote:
I have no idea what you mean here, can you elaborate?

I mean that unless he wants to write the objects he will be using, he'll need to install libraries to do those tasks. Such tasks might include creating a rectangle, or coloring a line. Unless he wants to both create a line/rectangle object, he will have to learn how to install a library, like DirectX, that he can use.

Naraku wrote:
There is no reason oblongoidbanana can't learn c++ and game programming simultaneously if that's how he/she want to do it.

Do you think it would be prudent, though, to learn the basics first? Mabey spend a month or two learning the basic algorithms etc.. before jumping into the murky waters of Video Game design? I am not saying he shouldn't, but I can see myself three years ago, and I would know that I wouldn't have had the skills, nor the ability to learn all of that information at a single time.

But then, whatever he does, it's his perogative. There is nothing stopping you from doing it, oblongoidbanana.

Good luck to you, in your endeavors.
Topic archived. No new replies allowed.