Oh, I thought stuff like that would get me circular imports. But I guess it won’t now that I think about it … thanks!
EDIT … circular imports, like:
player.py
from environment import Environment
from map import Map
class Player() # entry into the game
self.environment = Environment() # initial init of the environment
self.map = Map()
self.hud = self.environment.hud
self.hud.element.setText()
environment.py
from ingamemenu import IngameMenu
from hud import HUD
class Environment() # called from Player
self.ingamemenu = IngameMenu()
self.hud = HUD()
self.hud.element.setText()
ingamemenu.py
from environment import Environment
class IngameMenu() # called from Environment
self.environment = Environment()
self.hud = self.environment.hud
self.hud.element.setText()
map.py
from environment import Environment
class Map() # called from Player
self.environment = Environment()
self.hud = self.environment.hud
self.hud.element.setText()
EDIT 2:
On the IRC channel Hypnos suggested using a globals file, I assume like:
### player.py
from globals import Globals
self.globals = Globals()
self.hud = self.globals.hud
self.hud.element.setText()
### environment.py
from globals import Globals
self.globals = Globals()
self.hud = self.globals.hud
self.hud.element.setText()
### ingamemenu.py
from globals import Globals
self.globals = Globals()
self.hud = self.globals.hud
self.hud.element.setText()
### map.py
from globals import Globals
self.globals = Globals()
self.hud = self.globals.hud
self.hud.element.setText()
### globals.py
from hud import HUD
self.hud = HUD()
### hud.py
class HUD():
def __init__():
self.buildHUD()
But I often read globals are bad.