i have a question .my project is to design a game and i have a few questions.
1) i,m thinking of a game where the user uses the WASD keys to navigate a car .
how to i program in such a way that this works. pls explain step by step.
2)also how to make a program such that unless the user enters a specified key,the loop should not end.
pls inclued the header files,the functions and if possible a small simple example.
Hi welcome to the forum. You seem to be new here so I'll point you in a few directions that you're going to be thrown in eventually starting with: http://www.cplusplus.com/forum/articles/31015/
After all of that you'll want to choose a library that you are comfortable with so: http://www.libsdl.org/
and http://www.sfml-dev.org/
These are two of the most popular. Let us know which one you choose and we'll help you get started. C++ is a very strong language and as such there is a lot to know, don't let yourself get discouraged though as it is very rewarding to write your first game.
If we explained to you step-by step how to write the program, that eliminates half the fun of programming! I'm sure it would be a lot more fun (and realistic in terms of what might be programming later) if you worked it out on your own.
You will need a library to deal with the graphics, though. If you'll be using 2D graphics, I'd suggest using SFML. If you're going to use 3D, then probably the easiest (albeit not 100% bug-free) library is Irrlicht.
The problem with that is that yours would not immediately quit the loop... I hate to say this, but I think the only options here are to either:
1) Constantly check Running even inside the loop
2) Throw a custom exception that quits the loop
3) Use goto.
Though I might have missed something, and would be glad if anyone knew a cleaner solution.
@ hanst99: This is one reason that Win32 tells you to use a callback function to handle events, this way as soon as your case is met (ideally) it returns from the function and the rest of the code in the function isn't processed. There is nothing stopping this practice from being main stream on every platform other then people not wanting to deal with passing data structs.