A High Score Table That Survives
๐ฏ The top five scores, with names, kept in order and saved with the project.
๐ก The idea behind it
Inserting into a sorted list is a real algorithm, and it is the same one in every language.
๐งฑ Blocks you will need
listsinsert at of listdelete of listrepeat untiljoinitem of list
๐จ Build it
- Two lists: scoreNames and scoreValues, kept in the same order.
- At game over, ask for a name.
- Walk down the list: set i to 1, repeat until (i > length) or (score > item i of scoreValues) โ change i by 1.
- Insert the new score at position i in both lists.
- If the list is now longer than 5, delete item 6 from both. Display with a join of rank, name and value.
๐ Make it harder
- Handle a tie by putting the newer score second.
- Show the table sorted on the stage using a single text sprite and a join loop.
๐ Bugs you will hit
- Names and scores drift apart: every insert and delete must be done on BOTH lists, always in the same step.
- The new score never appears: your comparison is the wrong way round โ check > against <.
โฌ Need Scratch itself?
Free from MIT, in a browser or as an offline app that needs no connection at all.