Mail Archives: djgpp/1998/06/09/15:31:14
you have to make a function yourself using textout, and readkey.
Here is an example:
#include "allegro.h"
int get_input(char *string,int length,int x,int y,int c)
{
char strings[length];
int index,bs;
int keys;
for (index = 0;index <length +1;index++)
{
strings[index] = NULL;
}
index = 0;
simulate_keypress(32);
while (!key[KEY_ENTER])
{
keys = readkey() & 0xff;
if (key[KEY_BACKSPACE])
{
index --;
strings[index] = '\0';
bs = 1;
}
strings[index] = keys;
if (!bs)
index++;
textprintf(screen,font,x,y,c, "%s",strings);
if (index == length)
{
break;
}
bs = 0;
}
strcpy(string,strings);
return 1;
}
int main()
{
char *the_text;
allegro_init();
install_keyboard();
set_gfx_mode(GFX_AUTODETECT,320,200,0,0);
textprintf(screen,font,8,8,15,"enter your name");
get_input(the_text,15,17*8,8,4);
textprintf(screen,font,20,90,15,the_text);
while (!keypressed())
{};
remove_keyboard();
set_gfx_mode(GFX_TEXT,0,0,0,0);
}
Its, not optimized, but i just wrote it last night
Malcolm
malcolmj7 AT aol DOT com
- Raw text -