I've got a huge issue with pygame. Movement is always a bit jerky, even if the code is as simple as can be. Try running this simple example which moves a rect by 1 pixel at 60 FPS:
import sys
import pygame
pygame.init()
display = pygame.display.set_mode((640, 480), pygame.FULLSCREEN)
clock = pygame.time.Clock()
FPS = 60
def motion_test():
rect = pygame.rect.Rect((0, 240), (40, 40))
while 1:
# clear display
display.fill((0, 0, 0))
# check quit
for e in pygame.event.get():
if (e.type == pygame.QUIT or
e.type == pygame.KEYDOWN and e.key == pygame.K_ESCAPE):
pygame.quit()
sys.exit()
# move the rect by 1 pixel
rect.x += 1
if rect.x >= 640:
rect.x = 0
# draw the rect and flip the display
pygame.draw.rect(display, (255, 0, 0), rect)
pygame.display.flip()
# tick the clock
clock.tick(FPS)
if __name__ == "__main__":
motion_test()
No matter on what hardware I test this, the rect is moving jerky. Every like half a second or so, it "jumps" a bit. It's just not smooth motion.
Please, this makes me mad... does anybody know what might cause this? Is it pygame itself, or Python's garbage collection, or the OS, or just what? Any ideas? Do you see the same running the example?
(Win7 64bit, Pygame 1.9.1, Python 2.7.3)