0

I have tried pygame.transform.rotate and pygame.transform.rotozoom. Rotozoom works a little bit better, but my image flies off of the screen very quickly, and it stretches and morphs and won't just sweep left and right like I would like. My intention is when the rotation gets below -50 to rotate the other way, but that just stretches it more.

                try:
                    screen.blit(Turrets[0], (TurretCoords[0]))
                    if Rotation0 == -1:
                        TurretRotation[0] = TurretRotation[0] - 1
                        Turrets[0] = pygame.transform.rotozoom(Turrets[0], -1, 1)
                        if TurretRotation[0] < -50:
                            Rotation = 1
                        else:
                            Rotation = -1
                    elif Rotation == 1:
                        TurretRotation[0] = TurretRotation[0] + 1
                        Turrets[0] = pygame.transform.rotozoom(Turrets[0], 1, 1)
                        if TurretRotation[0] > 50:
                            Rotation0 = -1
                        else:
                            Rotation0 = 1

                except:
                    pass

                try:
                    screen.blit(Turrets[1], (TurretCoords[1]))
                    if Rotation == -1:
                        TurretRotation[1] = TurretRotation[1] - 1
                        Turrets[1] = pygame.transform.rotozoom(Turrets[1], -1, 1)
                        if TurretRotation[1] < -50:
                            Rotation = 1
                    elif Rotation == 1:
                        TurretRotation[1] = TurretRotation[1] + 1
                        Turrets[1] = pygame.transform.rotozoom(Turrets[1], 1, 1)
                        if TurretRotation[1] > 50:
                            Rotation = -1
                except:
                    pass
                pygame.display.flip()
Bigdog_00
  • 27
  • 5
  • Always rotate oryginal image with different angle. – furas Jul 13 '14 at 17:22
  • What exactly does that mean? Do you mean instead of constantly rotating with 1, to rotate with different numbers? – Bigdog_00 Jul 13 '14 at 17:23
  • BTW: there is ther rule (PEP8): use lowercase and '_' for variable names - for example `turret_rotation`. Uppercase use in class names. – furas Jul 13 '14 at 17:23
  • Why is that? Just curious. – Bigdog_00 Jul 13 '14 at 17:25
  • You rotat image (with angel `1`) to get new one, but then you rotate this new one (with angel `1`) to get newest one. To get newest one use oryginal image and use angle `2`. – furas Jul 13 '14 at 17:26
  • Oh! Thank you! I didn't understand why it just flew off the screen, but now I do. Thanks again! – Bigdog_00 Jul 13 '14 at 17:27
  • lowercast and upercase are to fast recognieze variables and clasess in all code - not only own code. – furas Jul 13 '14 at 17:27
  • oh. that makes sense. – Bigdog_00 Jul 13 '14 at 17:28
  • Even StackOverflow use light blue color to mark classes in code - but in your code all variables are light blue. – furas Jul 13 '14 at 17:28
  • see `PEP8` - [PEP 8 -- Style Guide for Python Code](http://legacy.python.org/dev/peps/pep-0008/) - it long document :) There are a lot rules. – furas Jul 13 '14 at 17:30

0 Answers0