class World(DirectObject): #client side making it easier and not having to log in everytime for debuging just follow the comments def __init__(self): print("began") self.taskMgr = taskMgr with open('config.json') as data_file: self.conf = json.load(data_file) self.ServerConnection = ServerConnection()#uncomment when going live self.ServerConnection.connect(self.conf['host'],self.conf['port'])#uncomment when going live props = WindowProperties( ) props.setTitle( 'Log In' ) props.setFixedSize(True) props.setSize(1280,740) props.setOrigin(-2,-2) base.win.requestProperties( props ) self.base = ShowBase self.main_theme = base.loader.loadSfx("assets/sounds/terminator_theme.ogg") self.main_theme.play() self.username = "" self.balance = "900000" self.authConnection = AuthConnectionModel(self)#uncomment when going live self.authConnection.setHandler(self.parseAuthResponse, self.parseRegResponse) self.ServerConnection.setupConnectionModel(self.authConnection)#uncomment when going live self.heartbeatConnection = HeartbeatConnectionModel()#uncomment when going live self.ServerConnection.setupConnectionModel(self.heartbeatConnection)#uncomment when going live self.taskMgr.doMethodLater(self.conf['heartbeatRate'], self.doHeartbeat, "heartbeat")#uncomment when going live self.taskMgr.doMethodLater(self.conf['heartbeatRate'], self.doHeartbeat, "heartbeat") self.screen = Login(self)#uncomment when going live #self.screen = Menu(self)#comment this one when you are trying to log into it like normal self.taskMgr.doMethodLater(self.conf['heartbeatRate'], self.doHeartbeat, "heartbeat") self.taskMgr.doMethodLater(1, self.doSong, "song") self.screenType = "login" self.screen.run() def doHeartbeat(self,task): self.heartbeatConnection.sendHeartbeat() return task.again def doSong(self,task): if self.main_theme.status() == self.main_theme.READY: self.main_theme.play() return task.again def doMenu(self): print("doing menu") self.screen.unloadScreen() self.screenType = "menu" self.screen = Menu(self) def parseAuthResponse(self,data): if data == 1: print("unloading") self.doMenu() else: if data == 2: self.screen.setStatusText("Already logged in") else: self.screen.setStatusText("Invalid username/password") self.screen.enter_btn['state'] = DGG.NORMAL self.screen.register_btn['state'] = DGG.NORMAL def parseRegResponse(self,data): if data == 1: print("unloading") self.doMenu() else: self.screen.setStatusText("User already exists") self.screen.cancel_btn['state'] = DGG.NORMAL self.screen.register_btn['state'] = DGG.NORMAL