Sign in to follow this  
djtschke

pygame questions (picture rotating and background scrolling)

Recommended Posts

djtschke    100
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 this post


Link to post
Share on other sites
Esys    156
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 this post


Link to post
Share on other sites
Captain P    1092
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 this post


Link to post
Share on other sites
djtschke    100
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 !

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this