input text into string using LWJGL?

i’m working on a scoreboard but am having difficulty reading text into a string from a keyboard, what would be the best way to achieve this in game?

with a console i would do

BufferedReader in = 
     new BufferedReader(
      new InputStreamReader(System.in));

try {                  
      StringWord = in.readLine();
     }

catch(IOException ioex)
{
      System.out.println("Input error");
      System.exit(1);
      }

all i need is characters read from keyboard for name on scoreboard, when enter is pressed it is done! is there an easy way to do this with LWJGL?

i am using bitmap fonts to display the text on screen.

thx

I’m afraid you’ve got to do it all from scratch. Fortunately I’ve done it a few times now and without going into too much detail I suggest you just download puppytron, play it until your fingers drop off, send me $5, play it some more, and only then look in the common.jar file and decompile the net.puppygames.applet.TextField class.

And yeah, we really do appreciate donations so we can keep writing code and helping everyone out :slight_smile:

Cas :slight_smile:

Heh Caspian i’ll send you 5$ if you write my game :slight_smile:

Only if I can burn the finished product on a CD and shove it up yer ringer widthways :-*

Cas :slight_smile:

thanks for your help, i sort of got it working, just how would you clear the keyboard buffer, because when i start reading the keyboard to string, all the previous key’s pressed on the keyboard load up first, is there a way to clear the buffer?

thx

Erh, what’s wrong with the Keyboard and Mouse classes in LWJGL?

  • elias

He wants a rendered textfield, not just input :wink:

To clear the buffer just do while (Keyboard.next());

Cas :slight_smile: