Help with hiscore table.

For questions about using Classic.

Post » Fri Oct 16, 2009 6:50 pm

Greetings everybody!
I couldn't find the information i want, so here is my first post.
I want to make a hiscore table for my game. An offline hiscore table that you can save it and auto load it every time you run the game. Your five best scores i want to be displayed so i need also a way to make construct understand if your current score is big enough to go to the hiscore table.
So please can anybody help me with this?

Thank you in advance.
B
1
G
3
Posts: 2
Reputation: 829

Post » Sun Oct 18, 2009 7:24 pm

You could use an array to store the scores. Then just use a loop to check each element in the array with the current score to see if it belongs in the high score table. You could sort the array as well.

To store the array you could use the .ini object to save the results out to and to load the results from.
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Sun Oct 18, 2009 7:53 pm

What scidave said isn't probably the worst idea.

Still I have a little cap for you using the List Box object. It's similar to an example I did for an online highscore using a flatfile. Click the blue square to get some points, enter your name and submit your score. Every time you submit a score the highscore will be saved to a file. Pretty simple and it's probably better to go the array/hashtable way somehow. Anyway I thought I'd share.

Highscore example: Download
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Sun Oct 18, 2009 8:59 pm

Thank you for your help, but my problem is something else now, 2 days am trying to fix this and is stll there. I want something very simple, save your highscore when you die or finish the game and load it when you run the game. Your highest score, not your score... so i make it like this...

Is global variable "score" Greater than global('hiscore')
then
System: Set global variable 'hiscore' to global('score')

i made an .ini file that looks like this...

[hiscore]
score=0

in order to save/load the @#$% highscore, so at the same moment follows...

INI:Write value global('hiscore') to item "score" in group "hiscore"

so far so good i can write in the ini file with the value i want, now to load it every time you run the game i made this...

Start of layout
System: Set global variable 'hiscore' to INI .ItemString("hiscore", "score")

and is working too, i can load the value from the ini file, but is not working together!!! I can save a value to the ini, i can load a value from the ini but when in my game the save and load action is together is not working, it loads the value but it can not save any new value later. Is like i have the load value action under an Always event and you cant change it.

Almost the only thing remains to finish my game is this.
My english is not very good, i hope you understand my problem. If more information is need it please let me know.

Thenk you all for your time and for your brain activity to solve my problem :)
B
1
G
3
Posts: 2
Reputation: 829

Post » Mon Oct 19, 2009 12:19 pm

[quote="GeoDee":29jn94vu]
and is working too, i can load the value from the ini file, but is not working together!!! I can save a value to the ini, i can load a value from the ini but when in my game the save and load action is together is not working, it loads the value but it can not save any new value later. Is like i have the load value action under an Always event and you cant change it.[/quote:29jn94vu]

I'd love to help you out there, but I can't say I do really follow. Maybe if you shared the cap, things would be easier.
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Tue Oct 20, 2009 8:52 am

has anyone posted a .cap example for online highscores? or an explanation?
B
134
S
65
G
16
Posts: 1,765
Reputation: 19,188

Post » Tue Oct 20, 2009 10:50 am

[quote="alspal":3hm7mlat]has anyone posted a .cap example for online highscores? or an explanation?[/quote:3hm7mlat]

I believe there was an older thread describing how to do it with php/mysql. Without a cap example though. I did an example simply using a flatfile (and php), but didn't share the source yet. Mainly because I wanted to set it up as some sort of tutorial, but didn't come around to do so. If you're interested in a flatfile example, I could probably help you out.
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests