The area of developing/designing/programming/etc. games? From what I've read of the tutorial on this site, there seem to be certain parts that make sense to be used and others that don't. For instance the I/O section makes sense and, while I haven't read it thoroughly yet, I assume the Object Oriented section makes sense.
Aside from those, and the ones that display text, I can't find an application for the other bits I've read. There probably is and I'm just overlooking it, but if anyone could point out how some of them are used in games, I'd be grateful.
(This is mainly referring to the tutorial, if that's not entirely clear. Which knowing me it probably wasn't.)
A huge chunk of the C++ language is used for game development. I/O is just the beginning. Everything from arrays and loops, to classes and functions are absolutely essential in developing the underlying game logic. I can't think of anything off the top of my head that is not relevant in some way to game mechanics.
Since I already have a thread associated with questions..Might as well use it, right?
Anyway, I've been experimenting with the if/else stuff and input/output commands. I know a lot of games use letters to trigger stuff like movement and so I tried to do something like that. Of course, it would just be to trigger a message like, you walked forward. Unfortunately, it only slightly works.
Here's the code to help see what I was trying to do:
int main ()
cout << "Please enter a command:";
cin >> w;
if (w == w)
cout << "You have chosen to walk forward.\n";
else cout << "You have chosen not to go forward.\n";
cout << "Choose a movement direction:";
cin >> a;
if (a == a)
cout << "You have chosen to walk westward.\n";
The problem is, whenever I hit W, it spits out the rest of the code that should only come out if I hit a different key. It works perfectly whenever I use numbers, so what's the issue with using letters?
About my initial question..I apologize for the vagueness of it. I'm not exactly great at asking questions about things that I don't grasp entirely.
int main ()
cout << "Movement Controls\n";
cout << "w = north\t" << "a = west\n" << "s = south\t" << "d = east\n";
cout << "Enter a movement direction: ";
cin >> direction;
if ( direction == 'w' )
cout << "You have chosen to walk north.\n";
elseif ( direction == 'a' )
cout << "You have chosen to walk west.\n";
elseif ( direction == 's' )
cout << "You have chosen to walk south.\n";
elseif ( direction == 'd' )
cout << "You have chosen to walk east.\n";
cout << "You have chosen to stand still!";
Your variable should be a char not int since you are entering one letter.
Don't get too ahead of yourself with this programming stuff. It only gets more and more in depth so if you don't understand something fully, you'll wound up getting lost sometime later.
I wasn't intending on getting ahead of myself really. I just felt like taking a break from reading the tutorial and experimenting a bit. It's really just a part of how I learn things, I learn something, and then I try to see how it works with other stuff.
Thanks for explaining that Return, I just got a bit used to the general int [insert whatever] then use that for input. Well, not to mention I just skimmed over the different types.
I can't think of anything off the top of my head that is not relevant in some way to game mechanics.
Well, there is: the evil, evil
Furthermore, you don't need
auto, register, inline
and most likely don't need
And I don't think exception specifications are of any use in games (they could be a Good Thing, they just have an impact on speed which is not acceptable). So no nothrow guarantee in destructors... (on the other hand, simply writing the specification woud result in the call of terminate(), which is most likely not better than a throwing destructor)
What you perhaps don't need and should avoid is multiple inherritance, the *void-pointer and builtin-arrays (because of speed and unmaintainablilty, lost type checking and stuped errors which are unneccessary).
Which leaves us with, ... well, the about 99.9% of C++ which are left.