0

I'm trying to add a score to my program, But when I run my code a black screen appears and it says that the app isn't responding. Without the score function it runs properly.

Here is my code:

def score_add():
    global score
    wait(1)
    score = score + 1
while not Game_Over:
    score_add()
text = font.render("Score: " + str(score), True, (0, 0, 0))
screen.blit(text, (10, 10))
pygame.display.flip()

I've tried removing pygame.display.flip() Same result.

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
Dragonsy
  • 21
  • 3
  • `pygame.display.flip()` is indented inside the while-loop or is outside as shown? – Scarlet Feb 18 '23 at 07:18
  • Its outside the while loop, but its still inside the "while running:" loop – Dragonsy Feb 18 '23 at 07:20
  • to update the screen, you need to use one of `pygame.disply.update()` or `pygame.display.flip()` [doc](https://www.pygame.org/docs/ref/display.html#pygame.display.update). And to let your OS know that your program is responding, you have to at least call `pygame.event.get` [doc](https://www.pygame.org/docs/ref/event.html#pygame.event.get) once in a while. But in the snippet you share, your program is stuck in the `while not Game_Over` loop and neither is reached. – Scarlet Feb 18 '23 at 07:30
  • You never leave the `while not Game_Over:` loop and the only thing this loop does is to call `score_add`. Of course the application is not responding. It's running the loop the whole time. – Matthias Feb 18 '23 at 12:31

0 Answers0