Chat on IRC |
scanf function in allegro
Posted by sksonic [send private reply] at December 16, 2001, 12:25:19 AM
I have been programming a game in DJGPP using the allegro game library and it seems that the scanf and other conio functions cannot be used. What should I use for inputting a string at a specific position on the screen (preferably in allegro's font 'font')?
Posted by sphinX [send private reply] at December 18, 2001, 07:37:01 PM
what do you mean they cannot be used? Allegro does not disable access to any standard functions, so i would suggest you elaborate a little as to what you meant by "cannot be used".
Posted by CodeRed [send private reply] at December 18, 2001, 08:13:23 PM
Did you include the conio header file? Use gotoxy(); to set the cursor at a specific point for output.
Posted by taubz [send private reply] at December 18, 2001, 08:57:08 PM
sksonic, you're probably looking for something that doesn't exist. scanf (what sphinx and CodeRed are talking about) is specifically a text-based function. You can't assume that any conio (CONsole input/output) functions would work in a graphics context.
- taubz
Posted by RedX [send private reply] at December 25, 2001, 10:48:14 AM
Actually it's stdio.h
Scanf should work, 'cus it operates on the keyboard buffer and puts the result to memory. It hasn't have anything to do with graphics. You should be abel to use scanf and pass the string to the functions of allegro to put it on the screen. What might cause the problem is the keyboard handler from allegro. (install_keyboard() ). It replaces the BIOS keyboard handler and my guess is that the conio functions can't handle the new one. (checked the manual and I was right on this one) RedX
Posted by sphinX [send private reply] at December 21, 2001, 04:59:18 AM
Of course, so if you really want to use scanf() I would suggest a call to remove_keyboard() beforehand, and then of course an install_keyboard() call afterwards. However, this seems a very inefficient way to input a formated string.
Posted by RedX [send private reply] at December 25, 2001, 10:46:27 AM
Could write your own string input function.
while (keypressed() ) { string[count] = readkey(); count++; } Ofcourse add some checks to prevent writting past the array. Or better: use a standard string class or the STL vector. RedX
Register as a new user | |||||||||