Ok, so this is how things stand now. I've read few books about C++ console programming, C++ console game programming, I'm doing C++ on school and I can say I'm pretty good at it. Now, I'd like to move on the next step, to program in C++ with graphics, sound, mouse input. I have started documenting and I found I can do this using libraries or something like this, but I'm not really sure where should I start if I want to make some basic PC games like maze games, card games, pong, tetris or even mario-like. I found about SFML, SDL, DarkGDK, DirectX, Xna, Opengl and few other things. So where should I start? What should I learn?
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster
As for the libraries, I would recommend to use well-established cross-platform libraries. For your purposes, SDL and/or OpenGL are candidates of choice. Start with SDL and add OpenGL when you want to take your graphics one step further.
Programming a graphics computer game is a lot different from simple console programs. There are several things to handle.
1) Multi-threading: Almost all graphics computer game have to run on more than one thread. Typically, you need a thread to loop and render the graphics, and a thread to capture and handle the user input. For handling threads, you should use either Boost.Thread or the C++ standard thread library (if you have a recent-enough compiler, with C++0x support), but these two libraries are basically the same anyways. The important part in this topic is to learn to work with a program that does several things concurrently, which is not an easy thing in general.
2) File-handling: Any computer game will have to rely on several files and file-types. Whether it is simply some BMP files, or audio files, or some more complex 3D models and environments, and other custom files, you will have to deal with this. You have to learn to select appropriate formats, appropriate external libraries to handle them, and learn to interface between external libraries (learn to use the "PImpl" idiom to your advantage, make a clear separation (or firewall) between your code and external libraries). File-handling also requires not so trivial resource management, keeping track of loaded files, releasing files no-longer used, etc. You should also consider employing a good serialization strategy in order to easily save/load the objects which constitute your game.
3) Event-handling: The main difference between simple console applications and graphics games is that your program is no longer in control of the execution, the player is in control. This is coined as "event-driven" programming. There are a lot of issues related to event-driven applications, including handling all the stupid, unpredictable things that a player can do. It also makes multi-threading all that more difficult because the timing of the interactions between threads is unpredictable and requires a lot of locks to synchronize things. Personally, I prefer to formulate my application as a multi-level stacked state-machine to handle the events depending on the state of the application, it helps you to clearly separate the operating modes and it reduces to combinatorial complexity of handling the events.
I would say that the next step is just to start using a library like SDL to draw a window and start adding simple event-handling and graphics. Take it one step at a time, play around with it, experience with it. When you feel confident, start working on a "real", "complete" game.
Edited by mike_2000_17 because: n/a
Mast3r67 0 Newbie Poster
To be honest, this was the kind of answer I was waiting for. It was very informative, detailed and constructive. Also, I'd like to ask: Are there are any advantages of using Linux over Windows for programming?
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster
>>Are there are any advantages of using Linux over Windows for programming?
hehe.. Do you really doubt it? Linux is far more comfortable for a programmer. There is only one compiler (or at least, one primarily used), which is GCC, so you don't get any problems with interfacing libraries or anything, all is uniform. All libraries and sources and everything is just one "apt-get install" command away. You never have to worry about linking issues. A host of great tools are available open-source and for free. etc. etc. Windows doesn't even compare. The motivation for using Windows is to distribute your app in the most used OS, but it is a terrible development environment, every other OS that exists is superior, coming from a programmer's perspective. But it's good to develop cross-platform code such that you can be fairly confident that compiling under Windows won't entail too much trouble. But the daily programming / compiling / testing / debugging is far more productive under Linux (even if not an expert with linux commands or anything).
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.