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
536 stars 188 forks source link

can you help me solve it please? #196

Closed icarpio closed 4 years ago

icarpio commented 5 years ago

pygame 1.9.6 Hello from the pygame community. https://www.pygame.org/contribute.html Traceback (most recent call last): File "c:\programdata\anaconda3\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "c:\programdata\anaconda3\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\ProgramData\Anaconda3\Scripts\pgzrun.exe__main.py", line 9, in File "c:\programdata\anaconda3\lib\site-packages\pgzero\runner.py", line 92, in main exec(code, mod.dict__) File "main.py", line 8, in from actors import Player, Asteroid File "C:\Users\Documents\Python Scripts\OpenCV\OpenCV\pgzero-master\examples\asteroids\actors.py", line 8, in class Player(Actor): NameError: name 'Actor' is not defined

icarpio commented 5 years ago

Games that are one file work 100% but those that are in several files (... main.py) give me an error, any advice?

icarpio commented 5 years ago

pygame 1.9.6 Hello from the pygame community. https://www.pygame.org/contribute.html Traceback (most recent call last): File "c:\programdata\anaconda3\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "c:\programdata\anaconda3\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\ProgramData\Anaconda3\Scripts\pgzrun.exe__main.py", line 9, in File "c:\programdata\anaconda3\lib\site-packages\pgzero\runner.py", line 92, in main exec(code, mod.dict__) File "flappybird.py", line 20, in storage.setdefault('highscore', 0) NameError: name 'storage' is not defined

lordmauve commented 5 years ago

Hi, this issue is fixed in the master branch on GitHub.

If you want a workaround for Pygame Zero 1.2, add from pgzero.builtins import * to the top of any .Py files you want to use except for the main one.

lordmauve commented 5 years ago

storage is a new feature in development and requires the GitHub version of Pygame Zero.

ba520y commented 4 years ago

Hi lordmauve, Thank you for giving us Pygame Zero.

Let me ask you a questoion. You said at above timeline

If you want a workaround for Pygame Zero 1.2, add from pgzero.builtins import * to the top of any .Py files you want to use except for the main one.

As an example, does that mean like below in the first 3 line of flappybird.py?

from pgzero.builtins import *
import pgzrun
import random

But I still get a same error as

NameError: name 'storage' is not defined

lordmauve commented 4 years ago

Storage is new in the master branch and you are using version 1.2.

For examples compatible with version 1.2, see the 1.2 branch, here: https://github.com/lordmauve/pgzero/tree/1.2release/examples

ba520y commented 4 years ago

Thank you for the information. I will try the latest version.