Yeah, it's difficult to re-organize my thinking. I'm used to C and Allegro 4, now trying to use C++ and Allegro 5. I had a hard time sleeping last night, just had programming on my brain. , I realized what my mistake was, and that is I need to create an input class of some sort.
I had set up what was needed for getting input the normal Allegro 5 way, in a loop as discussed in other parts of the forum, but that's no good in a game that has separate functions.
After looking at the demos I noticed A5teroids has an input class, that helped me see how to do it properly I think, I haven't created it yet but I am enthusiastic again. I am SO not used to programming in C++, I was ready to switch back to C but that would make no difference because as mentioned, I noticed that all the input examples online have to do with CONSOLE input, which I find strange in 2012.
One thing I am learning, all the tutorials online in the world can't replace just experience, trial and error. Most of the tutorials give bad examples and teach bad habits that don't work well in actual games.
"The easier your solution is, the harder it will be on you later on" seems to be pretty accurate. ]
Edit 1: How would you handle keyboard input in C? In C++ you have classes. I assume there would be global variables for events? It would be handy to know as I am still not so certain I want to program in C++.
Edit 2: Okay, I got it working without classes for now, although I DO want to try my hand at creating an input class.
I initialize queue and timer etc.. in an initialize() function, timer and queue are global variables (I'm in trouble now)...
Oh, display is also a global, I originally done this so I can have a shutdown() function that can be called from anywhere in the program which destroys bitmaps and other such things. Any suggestions for a better way is welcome, but this works, my globals are all grouped together so I can easily track them.
and then I have the wait_for_keypress() in it's own function...
while (event.type != ALLEGRO_EVENT_KEY_DOWN);
Now that I have this working, I think it should be easier to translate it into an input class if I so choose.