This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-09-01 19:56:00

AnnabelJ
New Scratcher
Registered: 2011-09-01
Posts: 1

How to create a high score list.

How do I alter the program so it doesn't end when all lives are lost, but keeps a record of the highest score attained?

Offline

 

#2 2011-09-01 20:27:08

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: How to create a high score list.

You'll have to use lists.  If you want to have names and numbers, you'll need 2 lists.  Otherwise, just use 1.  Each list, when the high scores are reset, should be empty and then filled with 5 or 10 items depending on how many you want.  I would recommend 5.  When the player finishes the game, he has a specific score.  Put this wherever this happens:

ask ["Name?"(you can put a limit on length if you want to keep it more organized)]
insert [answer] at item [1] of [names]
insert [score] at item [1] of [scores]
set [count] to [1]
repeat [5]:
     if <[item [count] of [scores]]<[item [count+1] of [scores]]>:
          insert [answer] at item [count+2] of [names]
          insert [score] at item [count+2] of [scores]
          delete item [count] of [names]
          delete item [count] of [scores]
     end if
     change [count] by [1]
end repeat
delete item [6] of [names]
delete item [6] of [scores]

This will add the score and name to the list if it's high enough and will delete the excess score (or just delete this score).  To display the scores, you can use variables, stamping, or just show the lists (not recommended).


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#3 2011-09-01 20:27:17

PlutoIsHades
Scratcher
Registered: 2010-10-18
Posts: 1000+

Re: How to create a high score list.

[blocks]<if><(  <<{Current Score  }>><{High Score  }>>  )>
<set{ High Score}to( <{ Current Score }>

Last edited by PlutoIsHades (2011-09-01 20:27:51)


Minecraft, Redwall, and Cyberchase fan, and PROUD.

Offline

 

Board footer