4 ms·
I 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
by ggggtez 7y ago
I 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.