How to use the pygame.quit function in pygame

To help you get started, we’ve selected a few pygame examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kidscancode / gamedev / snake / snake_oo.py View on Github external
def wait_for_key():
    # utility function to pause waiting for a keypress
    # still allow Esc to exit
    # Actually, we look for KEYUP event, not KEYPRESS
    if len(pygame.event.get(pygame.QUIT)) > 0:
        pygame.quit()
        sys.exit()
    keyup_events = pygame.event.get(pygame.KEYUP)
    if len(keyup_events) == 0:
        return None
    if keyup_events[0].key == pygame.K_ESCAPE:
        pygame.quit()
        sys.exit()
    return keyup_events[0].key
github Impelon / PyGVisuals / examples / design_chooser.py View on Github external
while going:
            # handle input events
            for event in pygame.event.get():
                if event.type == QUIT:
                    going = False
                group.update(event)
            group.draw(screen, background)
            pygame.display.update()
            pygame.time.wait(100)
    except Exception:
        # in case something does not work out...
        import traceback
        print("Something has gone wrong...")
        print(traceback.format_exc())
    finally:
        pygame.quit()
        sys.exit()
github Kinect / PyKinect2 / examples / PyKinectInfraRed.py View on Github external
frame = self._kinect.get_last_infrared_frame()
                self.draw_infrared_frame(frame, self._frame_surface)
                frame = None

            self._screen.blit(self._frame_surface, (0,0))
            pygame.display.update()

            # --- Go ahead and update the screen with what we've drawn.
            pygame.display.flip()

            # --- Limit to 60 frames per second
            self._clock.tick(60)

        # Close our Kinect sensor, close the window and quit.
        self._kinect.close()
        pygame.quit()
github CraigHissett / PiVidPlayer / buttons.py View on Github external
def terminate():
    pygame.quit()
    sys.exit()
github asweigart / PythonStdioGames / src / gamesbyexample / pygame_games / wormy.py View on Github external
def terminate():
    pygame.display.quit(); pygame.quit() # Display quit is a workaround for a Raspberry Pi bug.
    sys.exit()
github hta218 / Travel_Egypt / game.py View on Github external
def quit(self):
        sleep(1)
        pygame.quit()
        sys.exit(1)
github hypatia-software-org / hypatia-engine / hypatia / game.py View on Github external
def start_loop(self):
        controller = controllers.WorldController(self)

        while controller.handle_input():
            controller.handle_input()
            self.screen.update(self.viewport.surface)
            self.render()

        pygame.quit()
        sys.exit()
github buckyroberts / Source-Code-from-Tutorials / Temp / Pygame / 82_PythonGameDevelopment.py View on Github external
def pause():

    paused = True
    message_to_screen("Paused",black,-100,size="large")
    message_to_screen("Press C to continue playing or Q to quit",black,25)
    pygame.display.update()
    while paused:
        for event in pygame.event.get():
                
                if event.type == pygame.QUIT:
                    pygame.quit()
                    quit()
                if event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_c:
                        paused = False
                    elif event.key == pygame.K_q:
                        pygame.quit()
                        quit()

        

        clock.tick(5)