4 ms·
There isn't that much boilerplate with pygame (I've taught middleschool students pygame in the past); I'm not sure if it makes sense to move things into a frame
by archgoon 7y ago
There isn't that much boilerplate with pygame (I've taught middleschool students pygame in the past); I'm not sure if it makes sense to move things into a framework, and have a lot of configuration by convention, when the goal is education.
- ggggtez 7y agoI agree. Simply setting a magic global variable WIDTH and HEIGHT doesn't provide any insight, and confuses things more. There is no logical reasoning why those two variables are globals, and what other globals might have special behavior.
- jibe 7y agoI don't think there is much downside in starting with the good stuff (placing and moving pixels). You can, and will eventually expose more of the cruft as needed. But if you lose a students on day 1 because you spending the day configuring instead of creating, you may never get it back.
- ggggtez 7y agoYou have to take a step father to argue that this framework is better than just using boilerplate. If you need magic variables, you haven't actually fixed the boilerplate problem.
- kragen 7y agoPossibly you've made it worse: defining the wrong magic variable will pass silently, as I argue in https://news.ycombinator.com/item?id=22156525 https://news.ycombinator.com/item?id=22156525, while misspelling the name of display.set_mode will give you a traceback that tells you where the problem is. Of course most people didn't get into programming because they got excited about reading error messages...
- ducaale 7y agoActually pygame zero warns you if it detects that you have mispelled. For example of you use width, it will suggest that you use WIDTH. If you write onmousedown instead of on_mouse_down() it will also catch that and warn you.
- kragen 7y agoCool! So you have to get really far off before it doesn't notice?
- albertzeyer 7y agoYou can just give the student an already existing example. Then there is no time wasted in configuring etc. Just tell him, leave this cruft aside (put a comment in the code to make it simpler), and only touch this function, and that function. This is not really too hard. And when the student becomes more curious, at some point, he might want to try to understand parts of the cruft.
- dTal 7y agoHow so? Unless you plan to have multiple windows, of different resolutions (exceedingly rare in a video game), then WIDTH and HEIGHT simply are pieces of global state. Whether you like it or not, global state exists, and if you need access to it in many places, then passing it up and down the call stack becomes an exercise in pointless book-keeping.
- _carl_jung 7y agoGame programming is an area in which I feel benefits greatly from the use of global state.
- electronstudio 7y agoThe goal isn't education in how to make games or use a particular library. The goal is education in coding, and games are just the hook to maintain interest. Pygame Zero hides the bits we don't care about so they don't distract from the bits we do. Middleschool students might cope with full Pygame, but when you're teaching 8-year-olds who can't type quickly, getting a sprite on the screen without any boilerplate is an advantage in maintaining their attention. Another advantage of Pygame Zero is that the author was involved in the creation of Mu, and so Mu comes with Pygame Zero pre-installed. Having to install Pygame via pip would be a challenge for many kids. Anyway, Pygame Zero includes all of Pygame so you're free to introduce as much of it as you like.