Skip to content

Instantly share code, notes, and snippets.

@hortonew
Created January 11, 2013 00:38
Show Gist options
  • Save hortonew/4507033 to your computer and use it in GitHub Desktop.
Save hortonew/4507033 to your computer and use it in GitHub Desktop.
Pygame - Handle Events
import pygame, sys
from pygame.locals import *
running = True
pygame.init()
screen = pygame.display.set_mode((800,600))
clock = pygame.time.Clock()
def handleEvents():
global running
for event in pygame.event.get():
if (event.type == QUIT) or (event.type == KEYDOWN and event.key == K_ESCAPE):
running = False
if __name__ == "__main__":
while running:
handleEvents()
pygame.display.flip()
clock.tick(30)
pygame.quit()
sys.exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment