Когда игрок касается монет, счет обновляется и отображается, например, счет перекрывается, например, 1,2,3 и т.д., делая неясным, чтобы увидеть счет. Я пытаюсь получить его, чтобы предыдущий счет исчез и отображался только новый.
def main(): #my main loop
running = True
clock = pygame.time.Clock() # A clock to limit the frame rate.
score = (1)
score = str(score)
myfont = pygame.font.SysFont('OpenSans', 30)
textsurface = myfont.render('Level ONE: Greenland', False, (0, 0, 0))
background.blit(textsurface,(500,10))
textsurface = myfont.render('Score:', False, (0, 0, 0))
background.blit(textsurface,(10,10))
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
player_hit_list = pygame.sprite.spritecollide(player, coin_list,True)
for coin in player_hit_list:
textsurface = myfont.render(score, False, (0, 0, 0))
background.blit(textsurface,(90,10))
score = str(int(score)+ 1))
sprites.update()
screen.blit(background, (0, 0))
sprites.draw(screen) # Draws all of the sprites onto the screen
clock.tick(60) # Limit the frame rate to 60 FPS.
pygame.display.update()
I, кроме как в верхнем левом углу, показывает Оценка: 1, и когда к монетке прикасаются, она обновляется, например. Оценка: * * 1004