pygame questions (picture rotating and background scrolling)
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
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:
[Edited by - Esys on February 12, 2010 9:32:41 PM]
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]
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement