Probably you already noticed this.
I am using Windows XP pro, no service pack, python 2.4 and pygame 1.7.1 , ran
this script:
import pygame
from pygame.locals import *
from sys import exit
background_filename='sushiplate.jpg'
sprite_filename = 'fugu.png'
pygame.init()
screen = pygame.display.set_mode((640,480),0,32)
background = pygame.image.load(background_filename).convert()
sprite = pygame.image.load(sprite_filename).convert_alpha()
# Our clock object
clock = pygame.time.Clock()
# X coordinate of our sprite
x1 = -sprite.get_width()
x2 = -sprite.get_width()
# Speed in pixel(s) per second
speed = 250.
frame_num = 0
while True:
for event in pygame.event.get():
if event.type == QUIT:
exit()
screen.blit(background,(0,0))
screen.blit(sprite,(x1,50))
screen.blit(sprite,(x2,250))
time_passed_in_sec = clock.tick(30)/1000.
distance_moved = time_passed_in_sec*speed
x1+=distance_moved
if (frame_num%5)==0:
x2 = x2+distance_moved*5.
if x1>screen.get_width() or x2>screen.get_width() :
x1, x2 = -sprite.get_width(),-sprite.get_width()
frame_num+=1
pygame.display.update()
When I press and hold the mouse on the window title bar, the first sprite (The
one with x value blited = x1) advances, while the second one (The one with x
value blited = x2) is stuck in the same old x2 value, which makes me think that
the
if (frame_num%5)==0:
x2 = x2+distance_moved*5.
statements are not read while the mouse button is pressed in the window's
title. Also when I leave it for about 5 seconds, when I am sure value of x1
should be > screen.get_width() , the sprites are drawn from
x1, x2 = -sprite.get_width(),-sprite.get_width()
after I release the mouse button. The same happens if I leave the mouse button
from ~3 seconds up. It makes me think the if statement is not read as well
if x1>screen.get_width() or x2>screen.get_width() :
x1, x2 = -sprite.get_width(),-sprite.get_width()
Hope you have any ideas why this happens, and if you've experienced same issues
in other OSs and on Windows but with python 2.5 and pygame 1.8.
Cheers.
---------------------------------
Looking for last minute shopping deals? Find them fast with Yahoo! Search.