Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # more at youtube.com/hakology or hakology.wordpress.com
- import pygame
- from pygame.locals import *
- wWIDTH = 640
- wHEIGHT = 480
- def main():
- r = 1
- while(1): # do for a while (game loop)
- for event in pygame.event.get(): # handle events
- if event.type == QUIT: # ctrl+c
- r = 0 # return 0 = (game is over)
- elif event.type == KEYDOWN: # down arrow
- if event.key == K_ESCAPE:
- r = 0 # return 0 = (game is over)
- if event.key == K_q: # q key pressed
- r = 0
- GSURF.fill((0, 0, 0))
- if r != 1:
- break
- return r
- if __name__ == "__main__": # main function call
- r = 1 # set variable for return value
- pygame.init() # initialise python pygame
- GCLOCK = pygame.time.Clock() # set game clock
- GSURF = pygame.display.set_mode((wWIDTH, wHEIGHT)) # main game surface
- while r != 0: # quit if return not equal to 0 (0 = game exit, 1 = restart main loop)
- r = main() # get return value from main loop (1 == OK ... 0 == exit)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement