using allegro keyboard functions kills cin. It is possible, though time-consuming and slightly complicated (especially for noobs like me) to make a routine to recieve input, but why should we have to? Why does allegro not include a replacement function for cin? It supplies, like, a dozen for cout, so why not cin? It's just confusing.
1.) This is not a comment about Allegro.cc
2.) Name your threads better
3.) RTFM
Huh dude.
Just do not install_keyboard() and use the routines you want for keyboard input.
What CGamesPlay said.
Okay, I'll shut up... right after I do this
ISN'T IT REALLY ANNOYING WHEN PEOPLE TYPE IN ALL CAPS?!?!?!?!
oh, um, edit:
I put this in the wrong darn forum, too. Sorry.
Just to make sure you understand the basic principle:
You create a dialog with a textbox in it and once the dialog is dismissed read the value of the textbox.
See gstream if you are looking for a C++ way to handle input and output with Allegro. In short, it looks like this:
| 1 | #include <gstream> |
| 2 | |
| 3 | int main() |
| 4 | { |
| 5 | allegro_init(); |
| 6 | if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) < 0) |
| 7 | return 1; |
| 8 | |
| 9 | install_keyboard(); // when you use the inputter, you also have to |
| 10 | // initialise the keyboard |
| 11 | |
| 12 | gstream gs; // once again construct gs |
| 13 | |
| 14 | gs << "Try inputting a number: "; |
| 15 | |
| 16 | int number; // define a number |
| 17 | gs >> number; // get it |
| 18 | |
| 19 | gs << "\nYou wrote the number: " << number; // print it |
| 20 | |
| 21 | gs << flush; // remember to flush |
| 22 | |
| 23 | readkey(); // wait for a key to be pressed |
| 24 | |
| 25 | return 0; |
| 26 | } |
I've never used it and do not know how flexible it is. Note that you'll need to build the library yourself. (Or if you are using Dev-C++, install the DevPak.)
I've looked into it but if I remember correctly I found it too much overhead for too simple a task.
Yay, I am using Dev-C++! Dev-packs really simplify things.
Yay, I am using Dev-C++! Dev-packs really simplify things.
You can also use the Dev-paks with Code::blocks, which means you get the simplicity as well as a decent IDE.
I tried using codeblocks back in it's RC1 stage and wasn't too impressed. That was a long time ago (seems that way at least
LennyLen, has it improved much?
LennyLen, has it improved much?
Greatly. I only just started using it recently because I also wasn't impressed when I first looked at it years ago. Now I'm glad I gave it another shot. Visual Studio is the only IDE I've ever used that is better.
It's too bad gstream's input doesn't work well when your using other graphics along with it.