Re: [pygame] [Pygame] Smooth Animation
Hi Yannisv, I've written a module for Pygame that handles sprite animation for you. You can set each frame of animation to last for a specific number of seconds no matter what the frame rate is. The module is called Pyganim (Pygame Animation): http://inventwithpython.com/pyganim/ -Al On Thu, Nov 22, 2012 at 8:46 PM, Noel Garwick wrote: > Hey, OP, you may want to read and/or outright use this library: > http://inventwithpython.com/pyganim/index.html > > It has a partially written tutorial, but rather helpful examples. > > > On Thu, Nov 22, 2012 at 4:11 PM, Greg Ewing > wrote: > >> 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. >>> >> >> If you want smooth animation, you will need to create more >> animation frames. There's no way around that. >> >> -- >> Greg >> > >
Re: [pygame] [Pygame] Smooth Animation
Hey, OP, you may want to read and/or outright use this library: http://inventwithpython.com/pyganim/index.html It has a partially written tutorial, but rather helpful examples. On Thu, Nov 22, 2012 at 4:11 PM, Greg Ewing wrote: > 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. >> > > If you want smooth animation, you will need to create more > animation frames. There's no way around that. > > -- > Greg >
Re: [pygame] [Pygame] Smooth Animation
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. If you want smooth animation, you will need to create more animation frames. There's no way around that. -- Greg
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 .move_ip(0, -m) # image frames image_fps = 2# image_fps > 0 animt += tdelta if animt >= 1000.0/image_fps: animf += 1 .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.
Re: [pygame] [Pygame] Smooth Animation
On Thu, Nov 22, 2012 at 1: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. The obvious solution is to draw more frames, which is of course labour-intense. A less perfect solution is to change the animation frame once every 2 or more of movement frames. This will make the movement smooth and the animation slow enough, but it may look like the character's feet are sliding on the ground... -- Radomir Dopieralski, http://sheep.art.pl
Re: [pygame] [Pygame] Smooth Animation
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.
[pygame] [Pygame] Smooth Animation
Hello everyone. Just a quick question: I have made a character I can move around, and the walking animation consists of 4 frames. My problem is that if I set the resolution too high for a smooth movement animation, the frames change too fast, and if I set it too low, the animation is not smooth at all. It works like this: What should I do? Thanks in advance. -- View this message in context: http://pygame-users.25799.n6.nabble.com/Pygame-Smooth-Animation-tp346.html Sent from the pygame-users mailing list archive at Nabble.com.