Hi all, I figured it out lol. It was as simple as just passing the map
object as an argument to the keyboard function for the map keys.
sometimes I over complicate things!
On 11/3/2022 11:38 PM, Cody Hurst (codyt20) wrote:
Hi all,--
Thanks to the help I've been getting I've been making significant improvements in my python learning journey. I'm currently having a problem and would like some input before moving on.
In this game framework I'm building, I've got a player class, map class, and a key manager class which handles keyboard input. There is also the main file which imports the maptool.py player.py and keymanager modules. The maptool.py module has a method for receiving the player object and adding it to a list of players and some methods for moving the player as well. The move methods, like moveLeft, right, up down, etc are performing alterations on the player object stored in the list. Things like looking at the Player.name, Player.x values etc against the map x y and z values.
Probably silly of me, but instantiating the map object in the main file as well as a player object and then passing it to the object could only be accessed from within the main file and I was adding a print statement to the maptool module and was wondering why I wasn't seeing new players, just my default values for the map template.
So my question is this. Without having to import the main file to the maptool and key manager, because all 3 of them are already imported into the main file because I need access to them, how can I get keyboard input to the instance of the map object so my move method will work? I don't want to put the move methods in the main file because that is a function of the map itself.
Here is my recent, working and cleaned up code.
http://codyhurst.com/ol.zip
Thanks again for any help.