Python Forum
[PyGame] Rotating image issue
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyGame] Rotating image issue
#7
Quote:1. Store center point.
2. Rotate from original image.
3. Get image new rect.
4. Set rect.center with store center.

huuuh, I'm not so sure to what I have to do exactly.

So in my init let's say I have
        self.master_image = pygame.image.load("Sprites/Ant-rot.png").convert_alpha()
        self.masterrect = self.master_image.get_rect(center=(75,75))
        self.image = self.master_image.copy()
        self.rect = self.image.get_rect(center=(75,75))
and in the update part

        self.image = pygame.transform.rotate(self.master_image, self.perso_angle)
        self.rect = self.image.get_rect(center=self.masterrect.center)
when I do that my character is stuck on the right part of the screen. I'm quite lost on what I exactly have to do.

Quote:Also improve code.

yeah with each commit I try to remove/optimize useless/poorly written parts. If you had seen it when I first imported it from another code and then modified, I think you would have had a stroke ahaha.
Reply


Messages In This Thread
Rotating image issue - by Evoluxman - Oct-11-2019, 07:07 PM
RE: Rotating image issue - by metulburr - Oct-11-2019, 09:52 PM
RE: Rotating image issue - by Evoluxman - Oct-11-2019, 09:54 PM
RE: Rotating image issue - by metulburr - Oct-11-2019, 09:58 PM
RE: Rotating image issue - by Evoluxman - Oct-11-2019, 10:06 PM
RE: Rotating image issue - by Windspar - Oct-11-2019, 10:45 PM
RE: Rotating image issue - by Evoluxman - Oct-12-2019, 08:10 AM
RE: Rotating image issue - by Windspar - Oct-12-2019, 11:58 AM
RE: Rotating image issue - by Evoluxman - Oct-12-2019, 12:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Rotating a rectangle CompleteNewb 19 13,574 Aug-28-2021, 03:23 PM
Last Post: CompleteNewb

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020