# pygame questions (picture rotating and background scrolling)

## Recommended Posts

Hello everybody, here my two questions: -is it possible to rotate a blited image around another point that its center using pygame.transform.rotate ? - I tried to make a scrolling background for a sidescroller using the Surface.scroll function. Python tells my there is no such function ? Why that ? best regards and thank for the help djtschke

##### Share on other sites
1: the transform function only rotates the image around it's own center; it doesn't accept another point as an argument. To rotate an image or sprite around an arbitrary point, it's:

origin.x + (cos(angle) * (self.x - origin.x) - sin(angle) * (self.y - origin.y)),origin.y + (sin(angle) * (self.x - origin.x) + cos(angle) * (self.y - origin.y))

[Edited by - Esys on February 12, 2010 9:32:41 PM]

##### Share on other sites
To answer your second question, the Surface.scroll function was added in Pygame version 1.9.0. Are you sure you're up-to-date? If so, what was the exact error message that you got, and can you show us the code where you're creating and using that Surface object?

Now, personally I see no reason to use such a scroll function: you'd have to 'fill up' one of the sides of that surface with new content somehow, and then still blit that whole surface to the screen buffer, before drawing other game objects to the screen buffer. You could just draw the images that your scrolling background is composed of to the screen buffer directly, without an intermediate scrolling surface.

##### Share on other sites
I am still using pygame 1.8.1 for I encounter problems when trying to compile version 1.9. So that is the reason, thank you !

I didn't quite understand what you meant as a solution for my scrolling background. I am still pretty new to python and programming generally.

Thank you very much !

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628300
• Total Posts
2981899

• 9
• 9
• 11
• 10
• 10