Reputation: 49
I was testing things out in pygame. How come this constantly updates the position of my cursor
while 1:
pos = pygame.mouse.get_pos()
screen.fill(black)
screen.blit(ball,pos)
pygame.display.flip()
print pos
if pygame.event.get(27):
a = "exit"
While this doesn't?
while 1:
pos = pygame.mouse.get_pos()
screen.fill(black)
screen.blit(ball,pos)
pygame.display.flip()
print pos
if pygame.event.get():
a = "exit"
Upvotes: 4
Views: 804
Reputation: 161
it is to do with the way you have written pygame.event.get()
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT:
a = "exit"
pos = pygame.mouse.get_pos()
screen.fill(black)
screen.blit(ball,pos)
pygame.display.flip()
print(pos)
#here you should also include a pygame.time.Clock().tick(60) to set the FPS
Upvotes: 2