Hello Guest

How To Produce High Score Table

  • 13 Replies
  • 19584 Views
How To Produce High Score Table
« on: March 21, 2005, 14: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

How To Produce High Score Table
« Reply #1 on: March 21, 2005, 16: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.
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

How To Produce High Score Table
« Reply #2 on: March 21, 2005, 17: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

How To Produce High Score Table
« Reply #3 on: March 21, 2005, 17: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. :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

How To Produce High Score Table
« Reply #4 on: March 21, 2005, 17: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

How To Produce High Score Table
« Reply #5 on: March 21, 2005, 19: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)

How To Produce High Score Table
« Reply #6 on: March 21, 2005, 20: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

How To Produce High Score Table
« Reply #7 on: March 21, 2005, 21: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

How To Produce High Score Table
« Reply #8 on: March 21, 2005, 22: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

*

Offline sq

  • *
  • 5
shift or ctrl characters
« Reply #9 on: April 10, 2005, 03: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

ug02070
« Reply #10 on: April 27, 2005, 16: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.
M

How To Produce High Score Table
« Reply #11 on: October 21, 2005, 12:53:47 »
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..

*

Offline CaseyB

  • ***
  • 118
How To Produce High Score Table
« Reply #12 on: October 21, 2005, 14:36:09 »
This is how I've seen it done!  But I would love to see any suggestions to improve efficiency!  :D

How To Produce High Score Table
« Reply #13 on: October 22, 2005, 02: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?