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

Add special_flags to Group.draw() #3321

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

MarcellPerger1
Copy link

@MarcellPerger1 MarcellPerger1 commented Feb 1, 2025

Add special_flags to Group.draw(), fixes #3306.
I implemented this in the same way as in pygame/pygame#3722 for compatibility with pygame/pygame:

  • I added bgsurf as a (sometimes unused) 2nd argument to to all the Group.draw() methods so that special_flags is consistently the 3rd argument across all subclasses.
  • For LayeredUpdates.draw(), special_flags (if provided as non-None) overrides the blendmode of sprites.

In the docs, I haven't added the versionchanged because I don't know if the next version (or version where this will be merged) will be 2.5.3 or 2.6.0.

I haven't used fblits in this PR as I thought it might be better to do that in separate PR (let me know if I should do it in this PR)

I haven't added the `versionchanged` because I don't know if the next version will be 2.5.3 or 2.6.0
@MarcellPerger1 MarcellPerger1 requested a review from a team as a code owner February 1, 2025 11:10
@Starbuck5 Starbuck5 requested a review from dr0id February 1, 2025 20:26
@Starbuck5
Copy link
Member

In the docs, I haven't added the versionchanged because I don't know if the next version (or version where this will be merged) will be 2.5.3 or 2.6.0.

2.5.4, as of today :)

@@ -551,10 +555,11 @@ Sprites are not thread safe. So lock them yourself if using threads.
.. method:: draw

| :sl:`draw all sprites in the right order onto the passed surface.`
| :sg:`draw(surface, bgd=None) -> Rect_list`
| :sg:`draw(surface, bgsurf=None, special_flags=0) -> Rect_list`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

special_flags should default to None.

@aatle
Copy link
Contributor

aatle commented Feb 2, 2025

The feature is nice, but the implementation looks strange (it can't be changed though, for pygame compatibility).
Rather than adding a confusing unused bgsurf argument for all sprite groups to keep consistency with a single, rarely used LayeredDirty subclass, it would have been better to make special_flags keyword-only. Every code example given has used it as a keyword argument.
I also don't see why has bgd been renamed to bgsurf. This is technically a breaking change for LayeredDirty (though it probably won't have much impact).

@MarcellPerger1
Copy link
Author

I also don't see why has bgd been renamed to bgsurf. This is technically a breaking change for LayeredDirty (though it probably won't have much impact).

The only reason I changed it here is for compatibility with pygame, although it might be better just to keep it as bgd for compatibility with previous versions of pygame-ce (personally, I think compatibility with previous versions of pygame-ce is more important than compatibility with pygame).
I can change it back to bgd if you think that would be better.

@Starbuck5
Copy link
Member

(personally, I think compatibility with previous versions of pygame-ce is more important than compatibility with pygame).

I agree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow passing special_flags to Group.draw
3 participants