Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » cin

This thread is locked; no one can reply to it. rss feed Print
cin
Neil Black
Member #7,867
October 2006
avatar

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.

CGamesPlay
Member #2,559
July 2002
avatar

1.) This is not a comment about Allegro.cc
2.) Name your threads better
3.) RTFM

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

GullRaDriel
Member #3,861
September 2003
avatar

Huh dude.
Just do not install_keyboard() and use the routines you want for keyboard input.
What CGamesPlay said.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Neil Black
Member #7,867
October 2006
avatar

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.

CGamesPlay
Member #2,559
July 2002
avatar

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.

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

Matthew Leverton
Supreme Loser
January 1999
avatar

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.)

CGamesPlay
Member #2,559
July 2002
avatar

I've looked into it but if I remember correctly I found it too much overhead for too simple a task.

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

Neil Black
Member #7,867
October 2006
avatar

Yay, I am using Dev-C++! Dev-packs really simplify things.

LennyLen
Member #5,313
December 2004
avatar

Quote:

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.

Samuel Henderson
Member #3,757
August 2003
avatar

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?

=================================================
Paul whoknows: Why is this thread still open?
Onewing: Because it is a pthread: a thread for me to pee on.

LennyLen
Member #5,313
December 2004
avatar

Quote:

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.

julian_boolean
Member #8,201
January 2007

It's too bad gstream's input doesn't work well when your using other graphics along with it.

Go to: