lordmauve / pgzero

A zero-boilerplate games programming framework for Python 3, based on Pygame.
https://pygame-zero.readthedocs.io/
GNU Lesser General Public License v3.0
530 stars 190 forks source link

Without Update function childrens coding books projects fail to display. #267

Closed JeremiahCheatham closed 2 years ago

JeremiahCheatham commented 2 years ago

There are many kids coding book that use Pygame Zero as there tool kit for programing.

When my son tried to move from scratch to pygame with books like "Computer Coding Python Games for Kids" we quickly ran into many many issues. With me spending a lot of time scratching my head and trying to figure out what we were doing wrong.

Right away there is pgzero being locked to a version of pygame that is locked to python that may or may not be available on linux windows or mac. Meaning it may work but usually doesn't. At least that is how it was a year ago.

There was also the bug of the window not being fully created for SDL2 or pygame before pgzero giving use the issue with the mouse.

Related to this same issue is the fact that most of these childrens books we have 5 or more of them. Start out making projects that do not have the Update function meaning the screen is created 1 time and not refreshed. This means depending on how slow the SDL2 or pygame gets up and running before pgzero there may or may not be a black screen.

This is incredibly frustrating because all these books are saying this is the easy way to get into coding for kids but it ends up being a complete nightmare when you don't know if it's you that made a mistake or there is a bug and it's not always replicated. Through my constant efforts we did get though several books and i learned the tricks the very hard way to mostly get things working. But i think the average user would get stuck in the install phase or at the mouse or at the blank screens and finally give up. I have since moved on to using pygame zero and pygame and SDL2 in pure C in the time since first trying to code with my son for the first time in pygame zero. And nothing so far in C or Pygame has been so frustrating. Its really put me off and i think my son as given up and is back to scratch.

Shoot the Fruit project from that book.

apple = Actor("apple")

def draw():
    screen.clear()
    apple.draw()

def place_apple():
    apple.x = 300
    apple.y = 200 

I understand the state of the code and the place apple is incomplete but this is where the code asks you to try it. Now depending on luck this may or may not draw an apple in the top left. Because the code may complete before the actual SDL2 screen is ready i am assuming. however adding Update to the code will work since it will refresh. I found this out though just constant effort of trial and error that i think most people will not. And this same situation is in all the books over and over again. So either all the books are writing this wrong or there is a bug in the program.

apple = Actor("apple")

def draw():
    screen.clear()
    apple.draw()

def update():
    pass

Also in the same book 2 projects later there is a project that asks you to name it numbers.py this is probably just very bad publication since this will not work as it replaces the numbers module in python. Again I figure this out though just blindly trying 100 things. This is probably not your fault unless you wrote the book. But it just adds to the frustration of learning something when you don't know why things wont work and it's ends up not being your fault. And for kids its even worse.

JeremiahCheatham commented 2 years ago

In the same book there is a large 2 page list of all colors you can use in pgzero with there names to use in pgzero. The only problem is most of the names do not work at all in pgzero when it asks you to try them. I don't know again if this is the publisher writing a book and never trying it. Or if this did work on older versions. This was my whole adventure with this. Should be super simple but it also may or may not work and ends up being incredibly frustrating.

lordmauve commented 2 years ago

The screen not being updated or partially black without an update() function should be fixed by 126f7cf21e6c0cd493ddd14468f934f7506fa343 (this issue sounds like #248 and #247).

The colours issue is separate.