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

[Needs taking over]: Improve newbie guide#2718

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

Conversation

@davidpendergast
Copy link

  • Removed link to Python 2.0 Reference guide
  • Removed reference to (nonexistent?) module 'Userrect'
  • Removed advice about dirty-rect tracking (this advice is pretty outdated)
  • Added new section about outdated / obsolete advice that tends to float around the web (dirty-rect tracking, HWSURFACE)
  • Removed section about HWSURFACE
  • Updated code examples to python 3 syntax
  • Added note about how you have to clear the event queue even if you aren't using it
  • Added links to python profilers, and more a more up-to-date source about pygame/python performance

Zireael07, Starbuck5, illume, and javrr-ui reacted with thumbs up emojiStarbuck5 and illume reacted with hooray emoji
Copy link
Contributor

@Starbuck5Starbuck5 left a comment
edited
Loading

Choose a reason for hiding this comment

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

Line 22, supported OS comment: What even is BeOS? Maybe we should just claim Windows, Linux, and Mac.
Line 80, on multiple windows: It's not an SDL limitation now, so maybe we should just delete that whole sentence.

/docs/reST/index.rst needs to be updated, since it describes this as "A list of thirteen helpful tips for people to get comfortable using pygame." - and now it's actually 12.

Another enhancement would be to link the pygame functions to the pygame docs for those functions, for convenience of the reader. For example, ``pygame.display.set_mode()`` -> :func:`pygame.display.set_mode()`. Then it will be linked by Sphinx. You can generate the docs to test this stuff withsetup.py docs, although it has a hitch on Windows that Grimmy's and I are working out.

davidpendergast reacted with thumbs up emoji
@davidpendergast
Copy link
Author

Thanks, I'll make those changes.

One other thing I was thinking might be valuable is a section on distribution? One thing I notice a lot is people not considering cross-OS compatibility or packaging until they're completely finished with a project, at which point they fire up pyinstaller, a bunch of things don't work (e.g. reading asset files), they try and fail to fix them, and then get frustrated and give up.

It might be nice to suggest some things like:

  • using relative paths to reference all asset files
  • using os.path / pathlib to keep filepaths os-independent
  • (trying to) explain the quirks of pyinstaller --onefile mode

And maybe some other stuff like that?

@Starbuck5
Copy link
Contributor

There definitely could be a section about paths. I would recommend relative paths with the slashes like this ->"/". That will work on all operating systems. I frequently see newbies who have heard to use os.path.join, but do end up doing something completely useless with it, and since it isn't actually necessary, I think we shouldn't bring it up here.

PyInstaller is a bit more advanced, and it's something that needs a lot of explanation, so maybe it shouldn't be in the newbie guide either.

If we're brainstorming ideas for sections, it could be good to have some "hello world" code. I remember when I was learning pygame I found the game loop on some random website, and it really helped me. I also see people who don't knowClock exists, or who don't understand they have toflip(), or who just don't understand a basic pygame loop.

This is my personal brand of minimum viable pygame program:

importpygamepygame.init()screen=pygame.display.set_mode((1280,720))clock=pygame.time.Clock()whileTrue:screen.fill("purple")foreventinpygame.event.get():ifevent.type==pygame.QUIT:pygame.quit()raiseSystemExitpygame.display.flip()clock.tick(144)#framerate

@robertpfeiffer
Copy link
Contributor

Line 22, supported OS comment: What even is BeOS?

Has anybody tried compiling on Haiku?

@Starbuck5
Copy link
Contributor

Has anybody tried compiling on Haiku?

Let's keep it simple for the newbies guide.

@davidpendergast
Copy link
Author

I added a new section about software architecture and design patterns, which I think fits really nicely in this and gives a good opportunity to talk about the pygame "base template" and game loops in general in a more abstract way. Also made most of the suggested changes from comments - all that's left now (I think) is:

  • removing mention of SDL / multiple windows limitations (missed that one~)
  • linking function calls to docs
  • running setup.py docs to make sure it all looks right
    And I decided to just add a sentence to the 'learn python' section about paths, rather than adding a standalone section. I agree that distribution is probably too complex for this.

@robertpfeiffer
Copy link
Contributor

Has anybody tried compiling on Haiku?

Let's keep it simple for the newbies guide.

I'll make this its own issue then. I have no idea how well current Pygame runs on FreeBSD or Haiku.

@davidpendergast
Copy link
Author

Alrighty, I've made another update, which should address those few remaining issues I mentioned on the last diff and fix the HTML formatting issues (of which there were many).

Copy link
Contributor

@Starbuck5Starbuck5 left a comment

Choose a reason for hiding this comment

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

Looks good to me. 👍

Thanks for this@davidpendergast!

davidpendergast reacted with hooray emoji

There is NO rule six.
---------------------
Be wary of outdated, obsolete, and optional advice.
Copy link
Member

Choose a reason for hiding this comment

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

Against removing this part. Especially since dirty rect optimization is still useful.

Choose a reason for hiding this comment

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

Do you think it's useful to newbies though? Here are my main problems with the section:

  • Keeping track of dirty rects is error prone and beyond the capabilities of most newbies, from what I've seen. I worry that telling them to try it will lead them down a path of frustration (e.g. "my game is running is slow, I should try using dirty rects to fix it" -> they struggle to implement it properly and the FPS doesn't even improve).
  • Most beginner games can't benefit from dirty rect tracking anyways, due to having a moving camera + background image (e.g. flappy bird, top-down survival, platformers). And simpler games that could benefit (like snake, puzzle games, pacman etc.) likely don't need it to achieve high performance in the first place.
  • The way the section was written made it sound like pygamecan't run well without it, which makes pygame sound limited, slow & outdated. Prospective pygame users have asked about the display.update() -> 28 FPS maximum thing (this could be fixed with a rewrite)

I guess I'm just not sure who the target audience of this section would be, and what advice we'd want to convey beyond "this exists, but you probably don't need it?"

Copy link
Contributor

Choose a reason for hiding this comment

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

Dirty rect optimisation is not that useful. What might be useful is not re-drawing the whole screen, and instead only erasing and re-drawing a small section, but specifically the dirty rects parameter to update seems like a micro-optimisation these days.

@robertpfeiffer
Copy link
Contributor

Now that I think about it, a lot of perf advice like "avoid quadratic collision detection" or "don't use scrolling backgrounds to keep blits low" is situational, and the most important advice is "please benchmark instead of blindly guessing" and "move loading and rendering out of the game loop if you can".

@illumeillume modified the milestones:2.0.3,2.2Oct 23, 2021
@Starbuck5
Copy link
Contributor

Alright, I’d like this to move forward, since it is a needed modernization, so I talked to illume about how to get this ready to go.

The biggest sticking point is dirty rect optimization, illume says it’s still valid in some cases, and doesn’t want it presented as old advice. I think that it should be contextualized as an advanced technique, because beginners often mess it up when they try to do it.

Additionally, it was brought up in that the stuff about HWSURFACE doesn’t particularly belong in a newbies guide. I personally like the way Ghast put it in, but if we’re changing dirty rect that section might just go.

Maybe the dirty rect stuff could be more of a footnote in a performance section, that expands more on profiling.

I think illume and I both have an idea or two about how to get this fully up to par and merged, so either of us might take it over. But I’m also happy to leave it to Ghast, with those notes.

@davidpendergast
Copy link
Author

Feel free to take this over - it seems like you two have slightly different visions for this guide than I do so I'm probably not the best person to write up those ideas. I've also never personally used (or seen anyone use) dirty-rect optimization so my insight on that is limited. I hope my attempt at this was helpful at least though!

MyreMylar reacted with thumbs up emoji

@MyreMylar
Copy link
Contributor

Updated the title to indicate that this needs taking over. I think some good progress was made here but it needs somebody argumentative to get it over the line :)

If you want to take this over, either close this PR when you open a new one - or let me know that you want to take it over and I will close it.

Also: Please credit the author of this PR in your takeover PR.

@MyreMylar
Copy link
Contributor

I will have a go at taking this over.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@illumeillumeillume left review comments

+3 more reviewers

@robertpfeifferrobertpfeifferrobertpfeiffer left review comments

@ankith26ankith26ankith26 left review comments

@Starbuck5Starbuck5Starbuck5 approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

@MyreMylarMyreMylar

Projects

None yet

Milestone

2.3

Development

Successfully merging this pull request may close these issues.

6 participants

@davidpendergast@Starbuck5@robertpfeiffer@MyreMylar@illume@ankith26

[8]ページ先頭

©2009-2025 Movatter.jp