On another note, you appear to be aiming for a fixed frame rate, and at the same time determining how far to move your sprite based on the time taken in the last frame. If this is not what you want, you can get around it by either keeping a record of the up/down states of the keys you are interested in, or by using the _pressed interface. If you hold down, say, left, and tap right but keep holding down left, the sprite stops moving because the last event you processed was a keyup event, despite the fact that I'm still holding left. ((frame_count - action_start_frame) % animation_frames) * 150,Ī note about your event handling. If this is not the case, you'll need to record what the frame count was when the action started, and take this away from frame count before the modulo: area = pygame.Rect( If different actions have different numbers of frames, you'll have to update animation_frames when you update image_number.Īlso, this assumes that it's ok to play the animation starting at any frame. ![]() If you record the frame number in a variable, you can modulo this with the number of frames you have to get an animation frame number to display.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |