Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing special_flags to Group.draw #3306

Open
MarcellPerger1 opened this issue Jan 25, 2025 · 4 comments · May be fixed by #3321
Open

Allow passing special_flags to Group.draw #3306

MarcellPerger1 opened this issue Jan 25, 2025 · 4 comments · May be fixed by #3321

Comments

@MarcellPerger1
Copy link

MarcellPerger1 commented Jan 25, 2025

Description
Add a special_flags argument to Group.draw (and all the other group classes).
This would be useful as with this feature, I could write code like this:

group.draw(surface, special_flags=pygame.BLEND_RGBA_MAX)

instead of

for s in group.sprites():
    surface.blit(s.image, s.rect, special_flags=pygame.BLEND_RGBA_MAX)

Also, for more complicated group classes (eg. RenderUpdates), you have to copy the entire code of the .draw functions and change just the line where the .blit method is called which is quite annoying.

See pygame/pygame#3719 for the issue I opened over there (before I found pygame-ce).

@MightyJosip
Copy link
Contributor

Good idea, thanks for pointing it out. For someone who will try to implement i, try to see if https://pyga.me/docs/ref/surface.html#pygame.Surface.fblits could be used. Also, I think droid is modifying sprite atm, so maybe then we can implement this as well

@aatle
Copy link
Contributor

aatle commented Jan 31, 2025

The reason why fblits() could not be used currently is because it does not give back a rect of the changes.

This feature should be easy to implement though.

@Starbuck5
Copy link
Member

Honestly I wouldn't think this should be added, it's extra API for a niche use, could be accomplished by overloading draw (I think?), and philosophically I think sprites should be responsible for how they are drawn, not what group they are in.

However, since you've gotten this added to pygame/pygame, and we would like to be compatible with pygame/pygame, I guess we should do it.

@MarcellPerger1 Would you like to open a PR?

@MarcellPerger1
Copy link
Author

Yes, I'm happy to open a PR when I have a bit of time (probably this weekend)

@MarcellPerger1 MarcellPerger1 linked a pull request Feb 1, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants