So currently my code is
import pygame
def main():
pygame.init()
size = width, height = 800,700
backgroundColor = [0, 0, 255]
screen = pygame.display.set_mode(size)
screen.fill(backgroundColor)
pygame.display.flip()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
return
if pygame.mouse.get_pressed()[0]:
print event.pos
main()
What I am trying to do is that while the user is holding down the mouse, the position of the cursor is being recorded. What I have works except when you click off the screen, and then click back on the screen, if gives the error:
line 23, in main print event.pos AttributeError: event member not defined
How can I have get the same results as this code gives me, but when I click off the screen, and click back on, it wont give me an error?