[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [pygame] How to rotate a rect
> The rect object itself can't be rotated - it's edges have to be
> parallel with the x and y axis of the display surface.
> That said, an image itself can be rotated, using the
> pygame.transform.rotate() and pygame.transform.rotozoom()
> functions. Create an image surface with pygame.image.load(), then
> rotate it with either of the above functions - for example, to rotate
> image_surf by 45 degrees counterclockwise, I might call...
> new_surface = pygame.transform.rotate(image_surf, 45)
> Now new_surface will contain the original image, rotated 45
> degrees. As a result of this rotation, new_surface will be much larger
> than the original image_surf was, to accomodate the corners of the
> rotated image. You can blit away with new_surface now.
> Hope this helps.
I'm wanting to do a real time game where you control a boat(it is seen from
above). As you know ships are very tall.If it is in its normal state the
box will be tight but if it turns 45 degrees I am going to have a much
bounding box for the ship. It will make the game very unreallistic.Does
knows how to make it better? I am not only talking about pixel collision
but also bounding boxes that can be rotated, or anything that you know how
implement in python.
pygame mailing list