ug02070
Newbie

Posts: 34
|
 |
« on: March 21, 2005, 06:49:31 » |
|
Could someone suggest to me the easiest way to produce a high score table for my game? I have found a way to update the current high score but i could do with storing names of the top ten players really. do i need to dispose of the current game and then create a new window or something? As I would like the same background, would it be best to simply remove all of the models and then draw them on the screen? thanks
|
|
|
|
|
Logged
|
|
|
|
|
elias4444
|
 |
« Reply #1 on: March 21, 2005, 08:16:29 » |
|
I just store the top ten out to a text file, and then reparse the file on boot and save it after there's been an update.
To display the names, you'll want to build some kind of font system - there's a nehe tutorial in the lwjgl wiki about this that may help you. For myself, I create an object that stores a hashtable containing a texture for each font character, and then use a method to translate a string into a line of 2D texture mapped objects. That way, I'm able to take display whatever characters someone can throw at me.
|
|
|
|
|
Logged
|
|
|
|
ug02070
Newbie

Posts: 34
|
 |
« Reply #2 on: March 21, 2005, 09:18:23 » |
|
so should i just create a method that removes all models off the screen and use my font method to display everyhthing that is in a text file? what is the code to receive the player's name from within lwjgl, does it matter that they are typing into an opengl window or not? thanks
|
|
|
|
|
Logged
|
|
|
|
|
elias4444
|
 |
« Reply #3 on: March 21, 2005, 09:24:15 » |
|
How you draw it is completely up to you... overlay over 3dmodels, whatever - that's the joy of lwjgl. Quite often, your imagination is your only limit. I would parse the text file however, as I wouldn't want to display it directly as is (java sometimes puts little bits of data in there you don't want). As for picking up the players name, I use the Keyboard object included with lwjgl, and I check for valid characters with each input (if the user gets one of the high scores anyway). As they type it, I display the characters onto the screen, while also storing the characters into a string (make sure to account for the backspace key!). Honestly, this is very similar to how you would do it in plain Java - just using the lwjgl Keyboard object instead of the Java methods.
|
|
|
|
|
Logged
|
|
|
|
ug02070
Newbie

Posts: 34
|
 |
« Reply #4 on: March 21, 2005, 09:46:03 » |
|
sorry to sound stupid but could you possibly post a code snippet of what would display what the user enters and then write this to a text file plz? sorry, thanks  ps i do have the method to print the fonts once i pass the string to the method
|
|
|
|
|
Logged
|
|
|
|
ordoc
Newbie

Posts: 8
|
 |
« Reply #5 on: March 21, 2005, 11:27:42 » |
|
as far as writing out things to a file you would probably want to look at FileOutputStream in the java api. For receiving input from keyboard, its just like everything else except you "buffer" whats being typed.
psuedo code
if enteringNameforHighscores if(key not enter) name += key else return name
file.println(name + score)
|
|
|
|
|
Logged
|
|
|
|
ug02070
Newbie

Posts: 34
|
 |
« Reply #6 on: March 21, 2005, 12:31:10 » |
|
if enteringNameforHighscores if(!Keyboard.isKeyDown(Keyboard.KEY_RETURN)) getKeyName etc
is getKeyName the method that i need to use to detect what was entered? could someone plz include how to use this method plz? thanks
|
|
|
|
|
Logged
|
|
|
|
jam007
Newbie

Posts: 38
|
 |
« Reply #7 on: March 21, 2005, 13:27:25 » |
|
Reading the java doc at http://www.lwjgl.org/javadoc/ (liwjgl.input.Keyboard) I would guess that getEventCharacter is a good choice together with some checking for return and state. Anders
|
|
|
|
|
Logged
|
|
|
|
ug02070
Newbie

Posts: 34
|
 |
« Reply #8 on: March 21, 2005, 14:26:11 » |
|
sorry..know i am sounding stupid but i am not the best at java... i have tried the following to make sure i am getting the correct output.. System.out.println(Keyboard.getEventCharacter()); and have placed this within the main game loop but i get nothing  can someone tell me why plz and how can i use this to append to a string which will be written to a text file? sorry for all the questions thanks
|
|
|
|
|
Logged
|
|
|
|
sq
Newbie

Posts: 5
|
 |
« Reply #9 on: April 09, 2005, 20:40:38 » |
|
what if a player's name contains the character ' ? my string gets "contaminated with the character for Left or Right Shift how can one get clean characters...
thanks
|
|
|
|
|
Logged
|
|
|
|
MickeyB
Newbie

Posts: 10
|
 |
« Reply #10 on: April 27, 2005, 09:47:08 » |
|
You ever get an answer to this? I have found in lwjgl96 that the getEventCharacter is not returning anything either(actually appears to return a space/blank). Iposted over on jgo (apologies for crossing) and have not gotten an answer yet.
|
|
|
|
|
Logged
|
M
|
|
|
aurora
Newbie

Posts: 23
|
 |
« Reply #11 on: October 21, 2005, 05:53:47 » |
|
I just store the top ten out to a text file, and then reparse the file on boot and save it after there's been an update.
To display the names, you'll want to build some kind of font system - there's a nehe tutorial in the lwjgl wiki about this that may help you. For myself, I create an object that stores a hashtable containing a texture for each font character, and then use a method to translate a string into a line of 2D texture mapped objects. That way, I'm able to take display whatever characters someone can throw at me. are you using display lists? If not that might be slow for large amounts of text, also I'm not too sure if a hashmap is that efficient to be using every iteration of the loop..
|
|
|
|
|
Logged
|
|
|
|
CaseyB
Talks Too Much
  
Posts: 118
|
 |
« Reply #12 on: October 21, 2005, 07:36:09 » |
|
This is how I've seen it done! But I would love to see any suggestions to improve efficiency! 
|
|
|
|
|
Logged
|
|
|
|
aurora
Newbie

Posts: 23
|
 |
« Reply #13 on: October 21, 2005, 19:56:41 » |
|
As long as the strings of text are pretty constant through the game (ie. not a chat room, more like part of the gui) then a possibly faster approach is to incode a whole string of text in a displaylist. Is it possible to make this approach easier by having displaylists of displaylists or is doing that not very efficient?
|
|
|
|
|
Logged
|
|
|
|
|