0

I am writing a python (pgzero) project for a simple game with my teacher, but I wanted to improve it a bit. After adding something like a minimap, everything was fine, but after writing the next stage of the code, it stopped working completely. For other students who prescribed code identically to the teacher, everything works properly, unfortunately for me, it does not. Thank you in advance for any help. If more project code is needed I can share.

Terminal error:

Traceback (most recent call last):
  File "C:\Users\Olek\AppData\Local\Programs\Python\Python38\lib\site-packages\pgzero\clock.py", line 168, in tick
    cb()
  File "C:/Users/Olek/PycharmProjects/gra_mars_alfa/gra.py", line 533, in petla_glowna
    if mapa_pom[bohater_y][bohater_x] not in ob_mozna_stac:
NameError: name 'mapa_pom' is not defined

If I'm using terminal to run project terminal says:

PS C:\Users\Olek\PycharmProjects\gra_mars_alfa> pgzrun gra.py
pygame 2.1.0 (SDL 2.0.16, Python 3.8.0)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
  File "c:\users\olek\appdata\local\programs\python\python38\lib\runpy.py", line 192, in _run_module_as_main      
    return _run_code(code, main_globals, None,                                                                    
  File "c:\users\olek\appdata\local\programs\python\python38\lib\runpy.py", line 85, in _run_code                 
    exec(code, run_globals)                                                                                       
  File "C:\Users\Olek\AppData\Local\Programs\Python\Python38\Scripts\pgzrun.exe\__main__.py", line 7, in <module> 
  File "c:\users\olek\appdata\local\programs\python\python38\lib\site-packages\pgzero\runner.py", line 77, in main
    src = f.read()                                                                                                
  File "c:\users\olek\appdata\local\programs\python\python38\lib\encodings\cp1250.py", line 23, in decode         
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]                                             
UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 24633: character maps to <undefined> 
Olek
  • 1

1 Answers1

0

I says that the class: mapa_pom is not defined. Meaning that mapa_pom[][] is not what you wanted to use

your error is:

NameError: name 'mapa_pom' is not defined

your code is:

if mapa_pom[bohater_y][bohater_x] not in ob_mozna_stac:

so you are saying: if hero.x hero.y is not in list where_you_can_stand: 'code here'

if map[hero.x][hero.y] not in where_you_can_stand:
    'code here'

variable error example:

print(i)

Traceback (most recent call last): File "/home/pi/mu_code/i.py", line 1, in print(i) NameError: name 'i' is not defined

an_actor = Actor('not_here', anchor=('center', 'middle'))

Traceback (most recent call last): File "/home/pi/mu_code/i.py", line 1, in an_actor = Actor('not_here', anchor=('center', 'middle')) NameError: name 'Actor' is not defined

If this doesn't work please show me where in the code where you use mapa_pom and I might be able to answer it better.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 27 '22 at 18:54
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 28 '22 at 14:11
  • Where can I find this path: "/home/pi/mu_code/i.py" where should I replace the fragment? And this is the code in which I'm using variable "mapa_pom" and I get this error: ``` if mapa_pom[bohater_y][bohater_x] not in ob_mozna_stac: bohater_x = poprz_bohater_x bohater_y = poprz_bohater_y bohater_kostium = 0 ``` – Olek Feb 01 '22 at 20:34
  • (/home/pi/mu_code/i.py) I'm sorry that's from my computer :) – Samuel Sargent Feb 18 '22 at 18:39
  • So you are saying that if your character goes somwheres it's not supposed to, you reset it? – Samuel Sargent Feb 18 '22 at 18:52
  • again this might be your mapa_pom[bohatar_x][bohatar_y] object. – Samuel Sargent Feb 18 '22 at 19:03