Another Allegro question
Well you guys are on a roll and have been able to fix all my problems so far. So here is another question. I am playing around with Allegro right now (using DOS not Windows). I can output text on the screen with the best of them but I can't get input properly. This is my code right now:
#include <iostream.h>
#include <allegro.h>
const int scrx = 640;
const int scry = 480;
int main()
{
int number;
allegro_init();
install_keyboard();
set_gfx_mode(GFX_AUTODETECT, scrx, scry, 0, 0);
textout (screen, font, "Input a number:",0,0,4);
cin >> number;
while (!keypressed()) {}
return 0;
}
END_OF_MAIN()
What the program does is display "Input a number" on the screen. In the background though, it opens up another DOS box that is waiting for me to input "number". That is the problem because I want to be able to input "number" in the same window as the text. How do I combine them so it runs in one window? I kind of got an idea that I would have to make the Allegro code a function? However, I don't really know if that would work or not.
[edited by - aphid on December 26, 2002 11:16:37 PM]
If you read the Allegro documentation, it mentions that various functions are taken over by Allegro, meaning that the C(++) versions no longer work properly. Once Allegro has control of your keyboard, you need to use Allegro routines for low level keyboard reading. Apparently, you also need to use Allegro for higher level stuff. You may need to write your own input handler to take the single keypresses Allegro reads and turn them into something useful. Alternatively, if you just want a single digit, readkey() will return a single keypress, see the documentation to find out how to retrieve a digit from the coded keypress.
As far as I know, there are no high level input routines in Allegro, mainly since it''s designed to support games, where instantaneous detection of keypresses is usually more useful than string input.
As far as I know, there are no high level input routines in Allegro, mainly since it''s designed to support games, where instantaneous detection of keypresses is usually more useful than string input.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement