Blitting Text In Pygame
Im making a game to practice mygame and im creating a highscore screen but i cant seem to properly blit the text how i want here is the highscore method def high_screen(self):
Solution 1:
You could make a file for each score and then simply do something like:
screen.blit(label1, (0, 0))
screen.blit(labe2, (0, 100))
screen.blit(labe3, (0, 100))
#etc
Solution 2:
if your score is in a file which suppose looks like this:
score1 - 10
score2 - 23
score3 - 34
then you can use this to separate the scores into different texts
scorelist = [text.split('\n') for text in open('score.txt','r')]
##when you read the file from python you will get this string : score1 - 10\nscore2 - 23\nscore3 - 34
then to bit this onto a surface, use this code:
for i in enumerate(scorelist,1):
surface.blit(i[1],(100,100+i[0]*100))
Post a Comment for "Blitting Text In Pygame"