Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- import pygame, sys
- from pygame.locals import *
- pygame.init()
- (windows_width, windows_height, windows_title) = (600, 400, "PyGame Event")
- screen = pygame.display.set_mode((windows_width,windows_height),0,32)
- pygame.display.set_caption(windows_title)
- windows_bgcolor = (255,255,255)
- circle_pos = (0,0)
- circle_color = (255, 0, 0)
- circle_radius = 10
- #pygame.event.set_blocked([MOUSEBUTTONDOWN, KEYDOWN])
- block_flag = False
- mainLoop = True
- #initial data here
- while mainLoop:
- for event in pygame.event.get():
- if event.type == MOUSEBUTTONDOWN:
- if event.button == 1:
- circle_pos = event.pos
- if event.type == KEYDOWN:
- if event.key == K_SPACE:
- block_flag = not block_flag
- print 'MOUSEBUTTONDOWN is block: ', pygame.event.get_blocked(MOUSEBUTTONDOWN)
- if block_flag:
- pygame.event.set_blocked(MOUSEBUTTONDOWN)
- else:
- pygame.event.set_allowed(MOUSEBUTTONDOWN)
- if event.key == K_ESCAPE:
- mainLoop = False
- if event.type == QUIT:
- mainLoop = False
- screen.fill(windows_bgcolor)
- #create frame here
- pygame.draw.circle(screen, circle_color, circle_pos, circle_radius);
- pygame.display.update()
- pygame.quit()
- #destroy data here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement