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.