[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] I can't seem to find any simple sprite animation game examples on the pygame.org site
On 9/11/07, Lamonte Harris <pyth0nc0d3r@xxxxxxxxx> wrote:
Does anyone know of any simple animation games or scripts I can referrer to to see how they switch thru 2 images to make it look like they are moving.
Nor have I, but you could just have a frame counter: If the character is walking, for instance, and there are 10 frames in your walking loop, then:
if frame_number%10 == 0: #frame_number is a multiple of ten
#draw frame 1
elif frame_number%9 == 0: #frame_number ends in 9
#draw frame 2
elif frame_number%9 == 0: #frame_number ends in 8
#draw frame 3
elif frame_number%9 == 0: #frame_number ends in 7
#draw frame 4
elif frame_number%9 == 0: #frame_number ends in 6
#draw frame 5
elif frame_number%9 == 0: #frame_number ends in 5
#draw frame 6
elif frame_number%9 == 0: #frame_number ends in 4
#draw frame 7
elif frame_number%9 == 0: #frame_number ends in 3
#draw frame 8
elif frame_number%9 == 0: #frame_number ends in 2
#draw frame 9
elif frame_number%9 == 0: #frame_number ends in 1
#draw frame 10
...or something like that.