How To Produce High Score Table

Started by ug02070, March 21, 2005, 14:49:31

Previous topic - Next topic

ug02070

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

elias4444

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.
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

ug02070

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

elias4444

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. :D

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.
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

ug02070

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

ordoc

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)

ug02070

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

jam007

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

ug02070

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

sq

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

MickeyB

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.
M

aurora

Quote from: "elias4444"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..

CaseyB

This is how I've seen it done!  But I would love to see any suggestions to improve efficiency!  :D

aurora

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?