• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Python Python tutorial: apparently gamemap: GameMap in entity.py does not work?

Kaworu

Active Coder
Hi!

I am following the Python Roguelike tutorial. I am currently in the 6th part of it. And in my source code there is an error I cannot fix myself.

When I am trying to run main.py, the window with the game gets generated. However, when I try to make any move, an error occurs:

Code:
Traceback (most recent call last):
  File "C:\Users\DELL\Desktop\My_Roguelike\main.py", line 65, in <module>
    main()
  File "C:\Users\DELL\Desktop\My_Roguelike\main.py", line 62, in main
    oEngine.event_handler.handle_events()
  File "C:\Users\DELL\Desktop\My_Roguelike\input_handlers.py", line 32, in handle_events
    action.perform()
  File "C:\Users\DELL\Desktop\My_Roguelike\actions.py", line 89, in perform
    if self.blocking_entity:
  File "C:\Users\DELL\Desktop\My_Roguelike\actions.py", line 51, in blocking_entity
    return self.engine.game_map.get_blocking_entity_at_location(*self.dest_xy)
  File "C:\Users\DELL\Desktop\My_Roguelike\actions.py", line 17, in engine
    return self.entity.gamemap.engine
AttributeError: 'Entity' object has no attribute 'gamemap'

I am not really sure what is not working, but I have a suspicion. In entity.py I have a class Entity with a line:

gamemap: GameMap

And I believe that for some kinda reason, this is where things go bad (I think?). However, I have totally no idea WHY it's not working... :(

The full source code is on my GitHub, here. I would appreciate any help.
 
Top Bottom