views:

1976

answers:

6

I would like to know How to create a fps-game with SDL lib?

Are there any books that explain with examples?

A: 

Pretty much anything that says in the TItle the "Tricks of the Game Programming Gurus" is going to show you how to make a FPS game. LeMothe loves them.

Edit : forgot those titles.

Dan Blair
It'll show you how, but I don't consider them to be good. The one I read years ago was pushing all sorts of bad practices. Hardly "guru" quality.
rmeador
I agreed with you statement.
Dan Blair
A: 

I found this site a while back, when I was playing around with SDL, you'll find so sample programs you can download here

CheGueVerra
+2  A: 

Download the quake 3 sources at fileshack and learn from them.

A good point. Learning from the masters is never harmful. (though realize it may be dated, and even masters *can* make mistakes or not build for scaling)
David Frenkel
+11  A: 

this wins for most open ended question. You could literally write a book. But lets settle for pointing in the right direction...

Step one, you will need good debugging skills for a project like this. Pick up Code Complete by Steve McConnell. Read the whole thing. The time invested will pay for itself more than anything else you could read/experiment with.

Get your hands on some source code of some game. ANY game. Make sure you see something simple before you see something big and complex, and keep in mind when you look at any game code that they may have had a combined team put WAY more time into it than you will ever have. The point in this is to see code structure.

Get a reference for 3D math, doesn't have to be THAT in depth, but you will need to know stuff like dot products backwards and forwards, be able to figure out how to create the matrix for your camera in the world etc. (even if your writing 0% of the rendering code)

(edit) Here's a great book on 3D mathMathematics for 3D Game Programming and Computer Graphics, Second Edition (Game Development Series) This isn't the kind you learn in college, it's more like a cross between trig and more advanced practical concepts: How to create a toolbox for yourself of simple physics, efficient collision detection, etc.

You will need to know something about rendering, and pipelines. SDL gives you a leg up, but make sure you understand the concepts of what it's doing.

Read up about practical system design. Your various systems will have to interlock. Think it out well. Your system can be just a good in C or in C++, it's the THOUGHT that is put into how your data/control will flow that will count, NOT how perfectly you emulate design patterns (though these are very useful as well of coarse)

Fundamentals of AI, not "real" AI, but functional AI; there is a big difference. State machines are great to start with, and sufficient for a simple FPS.

Learn a little about estimation and planning. You will not have time to do everything you would want to do to properly make an FPS. You will have to both triage AND learn how to triage; they are 2 separate things, the latter being mroe difficult. Experience is the best teacher here of coarse. (though the legendary McConnell has book on this as well)

Have a system to insert your gameplay into your level. If it is JUST you as a programmer, then your best bet is to write a plug in for an already existing editing program such as 3DS Max. I would highly recommend Max over Maya for a programmer. Maya script is nice, but it is more geared toward clever non-programmers. I find 3DS Max to think more along the lines of how a programmer would about creating and editing your world.

You can spend YEARS making tools to let you do this right, so you want to do things in such a way that you can edit fast and accurately If you making your own editor, incorporate it into your game world. If your world is not TRULY 3D and you want to make lots of level fast you can save your level data as something like this, which will save you a lot of time Where X is a wall, the other letters are game objects which a dirt simple parser can translate into game objects and world coordinates

 xxxxxxxxxxxxxxxxxxxxxxxx
 xx..........P..........x
 xxxxxxx...........I....x
 xR....xxx...........E..x
 xx.................0xxxx
 xxxxxxxxxxxxxxxxxxxxxxxx

But it all depends on your game. My point is that you will need to resort to "ghetto coding" how you get your gameplay data into your world is very important and you need to think of something that is both fast for you to implement AND fast with you to work with.

And what it comes down to is what is your goal here? If it's to learn to code something the absolute right way, expect to spend most of your time iterating on code that seemed decent a month ago, but now that you realize what your requirements are, it could really use another pass. Do not be afraid to rewrite, you learn a lot by doing that, but if you goal is functionality, you will probably need to figure out where to hack some things in (like embedding gameplay data nad coordinates into code files) It IS ok to hack as long as you KNOW where you have hacked, and have carefully kept it separate from your good code so you can go back and properly write the code when you get the chance.

The bottom line is, you need to decide what your goal in this is, learning, or functionality and find the happy medium between.

David Frenkel
"You could literally write a book." Indeed, several have been written.
Dave Sherohman
+1  A: 

While not SDL specific, the NeHe OpenGL tutorials are an excellent place to start for learning about how to do 3D.

If this is your first game, you'll probably want to aim lower than an FPS. Writing a simple 2D Tetris game using SDL will teach you everything you'll need to know about that library.

Atiaxi
+2  A: 

Although the very long post is valueable in the long run, I feel it doesn't give the proper instant motivation of getting things on screen. Here's some facts, along with my opinion

-SDL is a 2D graphics library, you can't write an FPS in 2D, therefore you have to go with a 3D library, either DirectX, or openGL

-SDL has the ability to "sync" with openGL, using it for graphics, but there's not a whole lot of help online for that topic

I suggest you go to Lazyfoo.net, which is an absolutly amazing beginner's resource for game programming with SDL, it shows you how to draw to the screen, but also teaches you how to apply this to programming games. After going through this, you'll be able to make a tetris clone, or most other 2D type games

After this, you'll be ready for 3D(it's a lot more complex, requires a better grasp of math, and takes a lot more code to do simpler things) if you go with openGL, check out NeHe's Tutorials , they're currently working on a new set, using SDL with openGL, because the older tutorials, although valueable, are coded rather badly and use the windows(win32) API

keep in mind, game development is one of the most demanding, and rewarding programming you'll come across, so good luck

I've just started having a look at lazyfoo.net - awesome!!
Skilldrick