lundi 13 avril 2015

How to display time using a messagebox in python

Hi guys need a bit of help. I'm designing a tic tac toe game in python that times how long it takes the user to beat three levels and then saves this score to a file called 'Player Times.txt'. I want to rank the times each player gets to go from low => high.



print('You beaten all three levels and reached the end of the game!')
.windll.user32.MessageBoxW(0, "Hooray you've won the game.","Victory", 1)
ctypes.windll.user32.MessageBoxW(0, str(sum1), "Your Score", 1)
#top_score=str(input('Would you like to see the leaderbooard?'))
MyfileWrite = open('Player Times.txt','a')
MyfileWrite.write(file_info + "'s time is " + str(sum1) + '.' + '\n')
MyfileWrite.close()
print('--------------------')
top_score=str(input('Would you like to see the leaderbooard?'))
print('--------------------')
if (top_score=='yes'):
MyfileWrite = open('Player Times.txt', 'r')
file_contents = MyfileWrite.read()
print(file_contents)
MyfileWrite.close()


So this is what happens when you beat the three levels. You can then look at the leaderboard but it just prints out all the times that have been written to the file. What could i do to rank these times?


Aucun commentaire:

Enregistrer un commentaire