What is this "equal function" that the AI uses, exactly? Does it use the same "playerspeed" variable?
It might also be possible that you have a rounding problem, especially if you aren't limiting the frame rate (which seems to be the case). This might, for example, make you move faster in one direction than the other. To avoid these issues, you can store an "absolute" decimal position, and then each step find an integer "pixel" position from that each step which can be used for calculations, drawing, etc in the game. Alternatively, you can abandon the approach you're using and just go at a constant frame rate, say 60 FPS, and then define "pixels per frame" speeds instead of "pixels per second".
From: Thomas <pummer.thomas@xxxxxxxxx>
To: pygame-users@xxxxxxxx
Sent: Mon, January 31, 2011 6:22:46 AM
Subject: [pygame] PyGame Windows Key Behaviour
Hi there!
I've written a small demo pong game. There are 2 players, one is cpu
controlled. To sync there movement i use
clock = pygame.time.Clock()
and in the while loop:
milli = clock.tick()
seconds = milli/1000.
on checking the events it's:
if event.type == KEYDOWN:
if event.key == K_DOWN:
b_y += seconds * playerspeed
cpu changes his position with an equal function, until it reaches the
height of the ball
under winXP cpu and player can move with an equal speed
under win7 the player is significant slower than the cpu. it seems
that a player only can move 2/3 the distance than the cpu player is
able to
Do you have any hint's what can be done to fix this?
with kind regards
Thomas