I have an animation where my player swings his sword, with 5 images in pygame. The normal resting image is 14x22, and the rest are 13x23, 21x23, 18x23, and 18x23. I am having trouble with my character 'Jumping' when he swings his sword, since the size of my image is constantly changing. Could anyone help my with this?

Here's my code for the animation

elif keys[pg.K_SPACE]:
            now = pg.time.get_ticks()
                if now - self.last_update > self.frame_rate:
                    if self.direction == 'left':
                        self.game.player_img = self.game.playerattackleft[self.frame]
                        self.frame += 1
                        self.last_update = now
            except IndexError:
                self.frame = 0


  • 2
    \$\begingroup\$ It sounds like your system is missing the concept of a "hot point" or "registration point" used to align frames of different sizes. Is it safe to assume you've reviewed past Q&A about animating frames of different sizes? \$\endgroup\$ – DMGregory Mar 4 at 17:19
  • \$\begingroup\$ @DMGregory Yes I have read those, but I am unsure on how to implement a hot point into pygame. \$\endgroup\$ – Vincent W. Mar 5 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.