dMZX Forums: High Score Table - dMZX Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

High Score Table How to ...

#1 User is offline   RinGames06 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 21
  • Joined: 24-March 06
  • Gender:Male
  • Location:Mexico

Posted 15 October 2014 - 11:14 PM

Hi! I am building an Hi Score table for my remake, but i cannot figure it well ... I am using FWRITE FREAD commands. For 5 high scores. Any suggestions?
Thanks!
- RinGames -
1

#2 User is offline   ThDPro 

  • Brontosaurus-Sea-slug; Gooey and phallic
  • PipPipPipPip
  • Group: Members
  • Posts: 718
  • Joined: 03-December 06
  • Gender:Male
  • Location:Portland, OR

Posted 16 October 2014 - 02:06 AM

I don't know if this will be terribly helpful, but this is how I approached it just now. I'm totally certain there are better ways, but this is the one I opted for because I've done something kinda like it before and I knew it can work.

set "commands" "(10^6)"
set "list_length" 20
. "determines the amount of items on the list"
set "scores.txt" "fwrite_open"
loop start
set "$name&loopcount&" "RinGames0('loopcount'+1)"
set "$score&loopcount&" "('loopcount'+1*100)"
set "$name&loopcount&" "fwrite"
set "$score&loopcount&" "fwrite"
loop "('list_length'-1)"
set "" "fwrite_open"
give 1024 
. "all this is just so we can have a file to start with"
end
: "keyp"
clear mesg
zap "keyp" 1
take 10 SCORE
inc "rounds" 1
set "$player_name" "Thud&rounds&"
. "those are just to set up the test scenrio for multiple tests"
set "scores.txt" "fread_open"

. "this file will be laid out as:"
. "name1*score1*name2*score2*....etc"

loop start
set "$current_name&loopcount&" "fread"
set "$current_score&loopcount&" "fread"
. "worth noting, as long as the convention for fread/fwrite"
. "stays the same, you can add any number of things to the"
. "format, ex. SET $CURRENT_LEVEL&LOOPCOUNT& FREAD and so fourth"
loop "('list_length'-1)"
. "-1 is for the whole zero-indexing business, the first value will"
. "actually be 0"
set "" "fread_open"
. "close the read file, we're about to start writing"

. "okay, here's the funky part:"
loop start
if "SCORE" > "$current_score&loopcount&" "#INSERT_NEW_SCORE"
. "yes, believe it or not, you can do that crazy shit with strings"
loop "('list_length'-1)"
. "having ordered ordered the list, you'll now have to rewrite the file"
set "scores.txt" "fwrite_open"
loop start
set "$current_name&loopcount&" "fwrite"
set "$current_score&loopcount&" "fwrite"
loop "('list_length'-1)"
set "" "fwrite_open"
. "just so we can make sure this is working,"
goto "#DISPLAY"
* "DONE"
wait 10
restore "keyp" 1
end
: "#insert_new_score"
. "this shit's about to get complicated"
. "this may not be the easiest way to do all this"
. "I realize that now, but I'm having fun making it."
set "local10" "loopcount"
loop start
set "$current_name('list_length'-1-'loopcount')" "$current_name('list_length'-2-'loopcount')"
set "$current_score('list_length'-1-'loopcount')" "$current_score('list_length'-2-'loopcount')"
loop "('list_length'-2-'local10')"
. "This loop will take the rank where the new score should go"
. "and knocks everything down a notch so that the list will stay ordered"

set "$current_name&local10&" "$PLAYER_NAME"
set "$current_score&local10&" "&SCORE&"

. "and now we've put the new scores in their place!"

set "loopcount" "('LIST_LENGTH'-1)"
. "when you go back to the loop, this will stop it from continuing"
. "if it DID continue, it would just put the new values in every"
. "subsequent rank slot"
goto "#return"

: "#DISPLAY"
set "scores.txt" "fread_open"
change overlay c?? c00
loop start
set "$name&loopcount&" "fread"
set "$score&loopcount&" "fread"
write overlay c0f "&$name('loopcount')&  ||  &$score('loopcount')&" 1 "loopcount"
loop "('list_length'-1)"
set "" "fread_open"
goto "#return"


Dealing with fwrite/read and figuring out how to use it cleverly and easily takes banging one's head against the table for a VERY long time. I'm not sure I've ever met a situation where fwrite/fread didn't create a bug that needed fixing to make it work... That might just be me.

In any case, would love to help out, what specifically is the problem now?

This post has been edited by ThDPro: 16 October 2014 - 04:58 PM

original soundtracks
Better Than Nothing - DOMINATION - Commander Keen: Heroes Lost - Welkin - A Confectioner's Recipe - random ThDPro music stuff
<Risu21121> if you're not going to make a good game, you might as well make a blatantly racist one.
<Kuddy> Testicles.
"Where are my folder?" - KKairos
0

#3 User is offline   RinGames06 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 21
  • Joined: 24-March 06
  • Gender:Male
  • Location:Mexico

Posted 16 October 2014 - 04:38 PM

I am testing it. so many thanks :(
If i have any problems I will post a reply here.
- RinGames -
0

#4 User is offline   RinGames06 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 21
  • Joined: 24-March 06
  • Gender:Male
  • Location:Mexico

Posted 16 October 2014 - 05:49 PM

Posted Image

It=s kind of working. Now i will try to add the scores with counters and test the new score engine. :(
- RinGames -
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users