I am making a space shooter for my final year project and thought it will be cool to include a local score/ High score screen. I don’t know how to go about this and would really appreciate if someone can point me in the right direction, all the examples I found online look very complex to me. Also I want the score to be displayed on the game screen which is rendered with opengl es.
Thanks.
I am making a space shooter for my final year project and thought it
Share
I have just finished creating a high score board for my OpenGL ES game that I’m currently working on. As it’s for your final year project I won’t be using this as a pastebin, but instead give you some pointers. In my application the scores are sent to my PHP script which stores values in MySQL.
What I used:
When the game is over (all lives gone, timer up, etc) I use a line of code, not too de-similar to this:
The context is required so AlertDialogs and Toasts can be created. The constructor calls the function submit() which shows the AlertDialog asking for the player name, then sends the data to the server.
My class contains this line of code to let the player know if they reached the top 100 after a response was received from the server:
The high score list is stored in an ArrayList
And the data is padded using String.format in a similar fashion to this:
And Then:
within your Renderer’s onDrawFrame you could build the highscore class so you could call something like the one liner below, which would contain your translations, scales pushMatrix and popMatrix calls to draw the highscore data to the screen.
Which contains a loop, not too dissimilar to this:
Hope this helps to push you in the right direction, and best of luck with your project
A screenshot of my android app’s high score state rendered using OpenGL ES

EDIT: Sending Scores to PHP
This won’t be an exact copy and paste of my source, but hopefully there will be enough information here to give you the general idea of it all. My final code also gives the device a uniqid, which users can track all of their scores that have been stored in the database – but that’s something else.
php file:
I did mess around with signing requests, hashing scores, but for the purpose of my beta and getting the game published quicker I opted for just plain text entries. The code below, also does not detail highlighting the players submitted score, or getting rank based on time.
It should be noted that the $db object is a small class I made to wrap PDO methods prepare and execute, which return results as associative arrays
HighScore Android Class:
again, i won’t copy/paste but this will illustrate how to post data to a server, receive a JSON string, then pad the string and add it to the highscores ArrayList. The code below is the constructor for the HighScore class, it asks for the users input.
The SubmitAsync class is a subclass of the HighScore class, it will setup the http client to send data, and add the received data. The data is digested as JSON and strings are padded as mentioned previously, then added to the highscore ArrayList
That’s the very basics and alot more code than I would have liked to have entered onto here at any one time, and most definitely my longest post ever. I would seriously consider the comments of @Dan, and research local storage over my server based approach to a highscore board