[Tutor] high score lists

Kent Johnson kent37 at tds.net
Fri Apr 15 00:24:55 CEST 2005


R. Alan Monroe wrote:
>>Anyone have some good beginning ideas/references to creating a high
>>score list and storing scores in a simple python game? (if there's
>>something in the pygames module, or a simpler python way).  I'm
>>mod'ing a space invaders-type game and would like to add a high score
>>list :)
> 
> 
> Quick and dirty approach: make a list of tuples
> [ (40000, 'John Doe'),
>   (30000, 'Steve Austin') ]
> 
> You can append new ones to the end of the list, sort it, reverse it,
> etc.

And you can use the pickle module to save and restore the list.

Kent



More information about the Tutor mailing list