0

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()
Arthur Heuer
  • 23
  • 1
  • 6
  • Could you clarify the question? I don't understand what the title has to do with the question. – Joseph Chotard Mar 05 '17 at 21:42
  • The printing in Python has problems updating, hence, "Print problems". The problem occurs with Sublime Text 3, hence, "in Sublime Text 3". The window is a pyGame window, hence, "with pyGame". I was trying to keep the title short because that's what I thought people would prefer, so the meaning might be a bit condensed in the title. – Arthur Heuer Mar 06 '17 at 14:48

0 Answers0