views:

449

answers:

6

During the last 2 months I've been trying to learn the basics of game programming. So I coded a few simple games in Java to learn the fundamentals, such as Tetris, Checkers and Pac-Man.

Now I want to learn/improve my skills in C, so I have this idea of writing those games in C to learn more about memory management, no OOP, etc. I have done basic C programming before but never with graphics, so I don't know where to start.

Which libraries should I use to write simple 2D games in C? GTK+? Cairo libraries? Any tutorials you can recommend? Graphics libraries?

Thanks

+13  A: 

I would recommend using the SDL graphics libraries, there are some pretty good tutorials and demonstrations here... http://www.libsdl.org/ and for tutorials here... http://www.sdltutorials.com/ Hope it goes well!

Mark Iliffe
+3  A: 

Doing some openGL with glut is a good place to start in my opinion, as it allows you to do both 2d and 3d graphics.

http://www.opengl.org/resources/libraries/glut/glut%5Fdownloads.php

If you want another layer to help you with various parts of game programming (keyboard and mouse events, sound, etc..) you can use SDL with openGL.

http://osdl.sourceforge.net/main/documentation/rendering/SDL-openGL.html

There are lots of tutorials around the web to help get you started.

DShook
+2  A: 

Although the following are not 2d; as everyone is mentioning 3d i might add the following libraries; they are open source libraries for 3d engines.

Ogre is a pretty popular open source graphics engine. "Torchlight" was written in it, and so was "A tale in the Desert". Also the unreal engine has gone open source.

Hassan Syed
+3  A: 

If you want to do C game development, OpenGL with glut is a good start..

The red book is your friend!!

empc
Is this a good approach for 2D games? 3D games? Both?
davidrobles
OpenGL works very well for 2D and 3D. In both cases, though, you need to be very precise to set up a usable (for whatever definition of usuable you might be using) coordinate system. Once you get your head around the math, though, you're good.
Platinum Azure
blue book opengl superbible is quite decent, I recommend it.
ttvd
+1  A: 

A 2D library that just crossed my mind and is amazing to use is Quartz from OSX. The tools are pretty damn good as well. You'll have to learn some Obj-C though, but its a nice language.

Hassan Syed
+1  A: 

As someone mentioned you need some key Math skills to move up in the game programming world. I don't know how much is involved in animation and modelling since tools are available, but to write engines of any sort Linear Algebra is involved; this applies to 3D programming and it might be involved in 2D Opengl. Gilbert Strang's introductory book on Linear Algebra is amazing. Mit opencourseware also has an entire semesters worth of lectures available by Gilbert Strang on Linear Algebra. You can download them directly from Itunes or on the web.

Hassan Syed