I want my program to cycle through each player, and this code does that. However, on the last player, it displays the info then instantly clears it. I want it to wait for a user to press a keydown (like space or enter) before clearing the screen. I tried implementing this with event = pygame.event.wait() but now my program just hangs when it reaches that declaration.
players = {}
for player in range(1, int(num_players)+1):
name = ask(DISPLAYSURF, "Player " + str(player) + "'s name")
player_roll = None
while player_roll is None:
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
pygame.event.clear()
while event.type != pygame.KEYDOWN:
event = pygame.event.wait()
DISPLAYSURF.fill(WHITE)
FIRST_DICE = roll_a_dice()
SECOND_DICE = roll_a_dice()
player_roll = FIRST_DICE + SECOND_DICE
players[name] = player_roll
display_dice(FIRST_DICE, SECOND_DICE)
our_roll(name)
My full code is here: https://github.com/Legitimate/Street-Dice/blob/master/main.py
Here is a video of the issue: https://youtu.be/ChxZq0bY4wk