I'm using Sublime Text 3 as my Python IDE and Python with the pyGame library.
The problem is, the mouse only updates when I either move the mouse cursor out of or into the pyGame window. I tested this by moving the cursor in and out of the window a few times.
How can I fix this?
Thank you.
# Import pyGame
import pygame
import time
# Create the game window.
pygameInit = pygame.init()
if pygameInit[1] != 0:
raise valueError
gameDisplay = pygame.display.set_mode((800, 600))
# Name the game window.
pygame.display.set_caption("Spooky action at a distance")
update = pygame.display.update()
cycles = 0
gameExit = False
while gameExit == False:
mouseMoved = False
events = pygame.event.get()
start = time.time()
for event in events:
if event.type == pygame.MOUSEMOTION:
mouseEvent = event
else:
print(event)
if event.type == pygame.MOUSEMOTION:
mouseMoved = True
if mouseMoved == True:
start = time.time()
else:
end = time.time()
elapsed = end - start
if elapsed > 0.1:
print(mouseEvent)
if mouseMoved == True:
mouseMoved = False
cycles += 1
pygame.quit()
quit()