2016년 12월 5일 월요일

Constantly changing score keeper


I want to create an app that keeps score with objects constantly getting new points. Like this:

When Round one is done: A = 0 point, B = 1 points C = 2 points

Score:
C
B
A

When Round two is done: A = 1 point, B = 2 points, C = 0 points

B
C
A

Etc... So the letters keeps the points, and the scoreboard changes. Is there an tutorial app that does something like this, that I can build?

-- 
You can find that under the search term HIGH SCORE in this board.

-- 
No, not a high score... A score keeper or a score board.

--
Try this ...


--
Thank you! I will try it

--

Well, I tried that and I have come that far myself. What I want is a scoreboard that when something gets more points, it rises in the score. That is what I can't figure out. 

-- 
At this point, I am assuming you have a list of lists (a table),
with each row containing (name, score) and
they are stored in descending score order,
with the row with the highest score at position 1.

I also assume you have a stopper row with score 0 at the end, to make things easy on you.

This two column table can be used as a lookup table using the
lookup-in-pairs block, to tell you what score is in the table for a given name.

Say your new score is in global variable NewScore, for name PlayerName.
You want to see if PlayerName beat his old score, or if he is a new player.

If lookup-in-pairs(ScoreTable, PlayerName, default=0) < NewScore THEN
    (We want to clear any old score for that player, then insert his new score in the right place)
   For Index = length(ScoresTable) to 1 by -1
      If Select item 1 of (Select item Index of ScoreTable) = PlayerName THEN
          Remove item Index from list ScoreTable
   (end For loop)
   (old score cleared, now look for right place to insert new score)
  Set global InsertionPoint to 1
  While (select item 2 from (select item InsertionPoint from ScoreTable)) > NewScore 
     Set global InsertionPoint to InsertionPoint + 1
  (end While)
  (We have skipped past all the higher scores)
  Insert (make a list(PlayerName, NewScore)) at position insertionPoint in list ScoreTable
end If

-- 
Thank you, this seems to be what I'm looking for.

-- 

댓글 없음:

댓글 쓰기