0

here's what I want to do: I want to stop the time in pygame so that the player of my game can press 'enter' when they are done reading the dialog, and then the time can start running again.

however, when I try to do that, the program does nothing when I press the enter button. moreover, it crashes my program when I try to close it. I have been trying out everything I know, and when I couldn't figure it out I decided to come here to ask for help. here's my code for the first cutscene:

# time setup
    realtime = int(pygame.time.get_ticks() / 1000)

    # animations start here
    # cutscene 1
    if draw_scene_1:
        screen.blit(frame_0, (0, 0))
        pygame.draw.rect(screen, (0, 0, 0), (0, 0, 320, 480), 15)
        if realtime >= 1:
            loading(337, 99)
        fadein()
        if realtime <= 9 and realtime >= 3:
            channel1.play(pygame.mixer.Sound('missions\call.ogg'))
            time.sleep(9)
        elif realtime >= 9:
            screen.blit(frameE_0, (320, 0))
            pygame.draw.rect(screen, (0, 0, 0), (320, 0, 320, 480), 15)
        if realtime >= 12.5:
            screen.blit(dialE, (45, 300))
            textbox("hello?", 65, 340)
        if realtime >= 14:
            textbox("who is this?", 125, 340)
        if realtime >= 14:
            textbox("press enter to continue...", 330, 420)
        if realtime .= 15:
            pause(True)
        for event in pygame.event.get():
            if event.type == pygame.KEYDOWN and realtime >= 13:
                if event.key == pygame.K_RETURN:
                    pause(False)
                    draw_scene_2 = True

and here's the def code for the pause function:

    def pause(bool):
    while bool == True:
        pygame.time.wait(1000)

Any help would be appreciated.

icekete
  • 25
  • 1
  • 4
  • It is clear that if you call the pause function with bool equal to True, the program will hang, because it will enter an infinite loop. Maybe this will be helpful to you: https://stackoverflow.com/questions/18839039/how-to-wait-some-time-in-pygame – mbostic Aug 28 '21 at 15:50
  • Sorry, wrong link. I meant this: https://stackoverflow.com/questions/20748326/pygame-waiting-the-user-to-keypress-a-key – mbostic Aug 28 '21 at 15:55

0 Answers0