- Notifications
You must be signed in to change notification settings - Fork3.8k
[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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
davidpendergast commentedSep 13, 2021
- 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
Starbuck5 left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
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.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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:
And maybe some other stuff like that? |
There definitely could be a section about paths. I would recommend relative paths with the slashes like this -> 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 know 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 |
Has anybody tried compiling on Haiku? |
Let's keep it simple for the newbies guide. |
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:
|
I'll make this its own issue then. I have no idea how well current Pygame runs on FreeBSD or Haiku. |
…med appropriate, and double checked the formatting/wording in an actual html page
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). |
There was a problem hiding this 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!
Uh oh!
There was an error while loading.Please reload this page.
| There is NO rule six. | ||
| --------------------- | ||
| Be wary of outdated, obsolete, and optional advice. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?"
There was a problem hiding this comment.
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.
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". |
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. |
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! |
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. |
I will have a go at taking this over. |