Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Addspecial_flags argument toGroup.draw#3722

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@MarcellPerger1
Copy link
Contributor

I've added thespecial_flags argument to all theGroups exceptDirtyLayered tofix#3719.

I'm not sure whether to add thespecial_flags argument toDirtyLayered asDirtyLayered already partially handles this with theblendmode attribute on theDirtySprite objects.

@illume
Copy link
Member

illume commentedFeb 19, 2023
edited
Loading

Thanks :)

I'm not sure whether to add the special_flags argument to DirtyLayered as DirtyLayered already partially handles this with the blendmode attribute on the DirtySprite objects.

In my humble opinion, it would make sense for the DirtyLayered to support this, since it is a subclass. Probably all the subclasses that come with pygame should support it?

@illume
Copy link
Member

illume commentedFeb 19, 2023
edited
Loading

Looks like the file needs formatting with the black formatter.

python3 -m pip install black --userpython3 -m black src_py

@illume
Copy link
Member

illume commentedFeb 19, 2023
edited
Loading

There’s a type issue here:
https://github.com/pygame/pygame/actions/runs/4218255639/jobs/7323102489

cd buildconfig/stubspython3 -m pip install mypy --userpython3 -m mypy.stubtest pygame --allowlist mypy_allow_list.txt
pygame/sprite.pyi:208: error: Argument 2 of "draw" is incompatible with supertype "AbstractGroup"; supertype defines the argument type as "int"  [override][20](https://github.com/pygame/pygame/actions/runs/4218255639/jobs/7323102489#step:6:21)pygame/sprite.pyi:208: note: This violates the Liskov substitution principle[21](https://github.com/pygame/pygame/actions/runs/4218255639/jobs/7323102489#step:6:22)pygame/sprite.pyi:208: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides

@illumeillume added enhancement spritepygame.sprite labelsFeb 20, 2023
This is not perfect as `Group.dirty` has this as 2nd argument but this has it as 3rd argument.
@MarcellPerger1
Copy link
ContributorAuthor

The problem is thatAbstractGroup (and most other groups) have the draw method being

defdraw(self,surface:Surface,special_flags:int=0)->List[Rect]: ...

butLayeredDirty has the draw method being

defdraw(self,surface:Surface,bgd:Optional[Surface]=None,special_flags:int=0)->List[Rect]: ...

so code that takes any instance ofAbstractGroup and passes thespecial_flags as the 2nd argument would actually be passing it as thebgd argument if that instance turned out to be aLayeredDirty.

I can thing of 2 solutions:

  1. Make thespecial_flags argument keyword-only so that it can't accidentally be passed as thebgd argument toLayeredDirty
  2. Add an unused argument to the other draw methods so thatspecial_flags is always the 3rd argument.

@pygamepygame deleted a comment fromgresmFeb 21, 2023
@illume
Copy link
Member

  1. Add an unused argument to the other draw methods so that special_flags is always the 3rd argument.

I'm a fan of your second solution (except rename bgd tobackground orbgsurf). Because then there is a consistency with each of the classes draw methods.

Do you see any drawbacks with this solution 2?

(I couldn't find any code using a bgd keyword argument, so I think it's safe to rename)

Q: Is a blendmode(special_flags) attribute on sprite would be better here? IMHO, No. I think there's a use case where we want the special_flags to be used for the whole group. It's more convenient when you want everything to use the same

@MarcellPerger1
Copy link
ContributorAuthor

I agree that special_flags should be used for the whole group. Because then it will be consistent with all the other groups as the special_flags argument will always apply to everything in the group (and that won't depend on if its a normalGroup or aLayeredDirty)

@illume
Copy link
Member

Looks like there's a couple of pylint issues:

************* Module src_py.spritesrc_py/sprite.py:539:28: W0613: Unused argument 'bgsurf' (unused-argument)src_py/sprite.py:1169:16: W0612: Unused variable 'flags' (unused-variable)

Copy link
Member

@illumeillume left a comment

Choose a reason for hiding this comment

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

👍 thanks

@illumeillume merged commit9a033e8 intopygame:mainFeb 28, 2023
wang-r-j added a commit to wang-r-j/jumanji that referenced this pull requestMar 10, 2023
The pygame compatibility bugs with python 3.7 were first introduced inpygame 2.1.3.dev6 (pygame/pygame@a462721e) and were fully resolved in2.2.0.dev2 (pygame/pygame#3723,pygame/pygame#3722,pygame/pygame@aab517c7).So we can relax the requirement tightened ininstadeepai#67(instadeepai/jumanji#7dcd89f8) and just exlude 2.1.3.
@MarcellPerger1MarcellPerger1 deleted the group-draw-special-flags-arg branchMarch 11, 2023 21:14
illume added a commit that referenced this pull requestApr 30, 2023
…-argAdd `special_flags` argument to `Group.draw`
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@illumeillumeillume approved these changes

Assignees

No one assigned

Labels

enhancementspritepygame.sprite

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Allow passingspecial_flags toGroup.draw

2 participants

@MarcellPerger1@illume

[8]ページ先頭

©2009-2025 Movatter.jp