0
def pause_screen():

paused = True

while paused:
for event in pygame.event.get():
  if event.type == pygame.QUIT:
    pygame.quit()
    quit_game

  if event.type == pygame.KEYDOWN:
    if event.key == pygame.K_c:
      paused = False

  screen.fill(WHITE)
  largeText = pygame.font.Font(None,50)
  screen.blit(largeText.render("Paused!",True,BLUE),(135,40))
  largeText = pygame.font.Font(None,35)
  screen.blit(largeText.render("Pressed c to continue the game!",True,BLUE),(135,40))
  button("Quit", 130, 350, 150, 60, RED, GREEN, quit_game)
  button("Return to main menu", 130, 450, 350, 60, RED, GREEN, front_page)

  pygame.display.update()
  pygame.display.flip()
  clock.tick(60)

      if keys[pygame.K_p]:
      return pause_screen
     if keys[pygame.K_c]:
      return menu

I am making a ping pong game, currently when I pressed p key it takes my to the paused menu, however when I press the c key it doesn't take me back to the game where it left off

  • There isn't enough information in this post to answer your question, but it can be assumed that you're defining your paddles initial position variables inside your game function. By doing this, every time you run your game function it will redefine all of your variables to default. To avoid this, define your initial variables outside of your game function and use "global " inside of your game function for every variable you want to keep. – Zan3y Apr 26 '22 at 17:59
  • I have redone it and it works now – Jayason THAVATHEVATHASAN Apr 28 '22 at 16:39

0 Answers0