[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] [Pygame] Smooth Animation



Hi, you can use "time-based" animation.

animt = 0# actual frame time (int)
animf = 0# animation frame (int)

fps = 100
clock = pygame.time.Clock()
while True:
	tdelta = clock.tick(fps)# ms from last tick

	# movement
	pixels_per_second = 100
	m = (tdelta / 1000.0) * pixels_per_second
	<sprite>.move_ip(0, -m)

	# image frames
	image_fps = 2# image_fps > 0
	animt += tdelta
	if animt >= 1000.0/image_fps:
		animf += 1
		....
		<sprite>.image = images[animf]
		
	


On 11/22/2012 01:08 PM, yannisv wrote:
Yes, I am. The problem is when I set the FPS to ~12, and use clock.tick(FPS)
inside the loop, that movement looks terrible (as expected). When I set the
FPS to 30 or 60, the movement does look better, but the frames change
extremely fast.



--
View this message in context: http://pygame-users.25799.n6.nabble.com/Pygame-Smooth-Animation-tp346p348.html
Sent from the pygame-users mailing list archive at Nabble.com.