[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] weird problem with pygame.mouse.get_pos() and print
Hi,
I'm currently using Python 2.6.1 and Pygame 1.8.1. The following code
does not work:
import pygame, sys, os
from pygame.locals import *
pygame.init()
class Window():
X = 640
Y = 480
Resolution = pygame.display.set_mode((X, Y))
Surface = pygame.display.get_surface()
def inputmouse():
(MouseX, MouseY) = pygame.mouse.get_pos()
if MouseX > 10 and MouseX < 210:
print "test2"
while True:
inputmouse()
However, simply adding a print statement outside of the "if statement"
causes the code to work, like this:
import pygame, sys, os
from pygame.locals import *
pygame.init()
class Window():
X = 640
Y = 480
Resolution = pygame.display.set_mode((X, Y))
Surface = pygame.display.get_surface()
def inputmouse():
(MouseX, MouseY) = pygame.mouse.get_pos()
print "test1"
if MouseX > 10 and MouseX < 210:
print "test2"
while True:
inputmouse()
Can someone tell me whats going wrong. I had pygame.mouse.get_pos()
working earlier but now it doesn't. I can't see why a simple print
statement would cause the code to work but it does. I have already
posted this question on the Python Forum and since then I attempted
running the code on Python 2.5.4 with Pygame 1.7.1 which had the same
result.