Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Help with simple highscore

Author
Message
Cyborg ART
19
Years of Service
User Offline
Joined: 14th Jan 2007
Location: Sweden - Sthlm
Posted: 23rd Jun 2010 17:24
Hi!

I am currently in need of a very simple highscore which basicly compares the old highscore with the players score. If the players score is higher then it would delete the scorefile and make a new with the new highscore.

I got this code:



I know that byte only holds 255, but when I write a byte it works (almost.. if the players score is lower than the highscore then that gets the new highscore... )

Any help is appreaciated.

Its quite urgent

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 23rd Jun 2010 18:31
It's probably not working right because you're using different forms of data.

If you didn't define score as a float (a number with a decimal) earlier in the code it's an integer (a number without a decimal) when you check if the score is greater than the high score. Then you write the result down as a byte (which your right about) so the score can only be between 0 and 255.

It's better to make them all integers so the score can be higher than 255. Use WRITE LONG and READ LONG to use integers (drop the # from highscore# so it's not a float).

Here's the limits of each data type and the amount of bytes they take up in files:



Cyborg ART
19
Years of Service
User Offline
Joined: 14th Jan 2007
Location: Sweden - Sthlm
Posted: 23rd Jun 2010 19:19
Thanks!
Now it worked!

Didnt knew there was a way to write integers to a file. You learn something new each day

Once again thanks! You saved my day!

Login to post a reply

Server time is: 2026-07-25 08:13:36
Your offset time is: 2026-07-25 08:13:36