pygame-community / pygame-ce

🐍🎮 pygame - Community Edition is a FOSS Python library for multimedia applications (like games). Built on top of the excellent SDL library.
https://pyga.me
853 stars 140 forks source link

Rotation won't work in _sdl2.video.Texture. #2776

Closed gungugugungu closed 6 months ago

gungugugungu commented 6 months ago

Hi! I'm currently working with pygame._sdl2.video for rendering, and I ran into an issue. I'm trying to rotate a texture, and the only way I found to to it is with angle parameter in texture.draw(). I did what I could, but it just doesn't rotate.

Code:

def blit_rotate_texture(texture:Texture, pos:tuple[int, int], angle:int, size=(-1, -1)):
    if size == (-1, -1):
        size = (texture.width, texture.height)
    dist = (pos[0], pos[1], size[0], size[1])
    texture.draw(dstrect=dist, angle=angle)

later used: blit_rotate_texture(texture_blue, (64, 160), angle, (64, 64))

the image actually renders all scaled like it's supposed to, but it doesn't rotate.

oddbookworm commented 6 months ago

Thanks for the report @gungugugungu! If you don't mind, could you provide a standalone minimal code example that reproduces the behavior you're seeing?

gungugugungu commented 6 months ago

Hi! Sorry for bothering at all, I just messed up the math, I checked out everything except for this. Here is what caused the issue:

    angle += 1
    if angle <= 361:
        angle = 0

I'll close the issue with this comment.