def selectionItem(state): global isOpen if state == "down": if isActive and isOpen and (usedInterface != None): currentItem = usedInterface.getEntry("currentLine") if (currentItem == 1): # save the game Data.setData("isNewGame", False) Data.setData("lastPosition", playerBehaviour.getPlayer().getPosition()) Data.setData("lastScene", sceneBehaviour.getCurrentScene().getFileName()) Data.saveData() print('Game saved...') usedInterface.delete() Global.setInterfaceOpen(False) playerBehaviour.setControlsEnabled(True) isOpen = False characterBehaviour.stopMouvementForAllCharacters(True) else: os._exit(99)
def run(self): engine_data = { "data_id": self.data_id, "data_data_id": self.data_data_id, "data_event_type": self.data_event_type, "logic_id": self.logic_id, "func_name": self.func_name, } try: Data.status(engine_data, "START") self.init_engine_logic_dir() self.load_logic_2_local() Runtime.execute_logic(engine_data) except Exception as e: Data.log(engine_data, "TRACE", str(e))
def startApp(): # get saved data before game start screenSize = Data.getData("screenSize"); Global.setScreenSize(screenSize[0], screenSize[1]); settings = pygame.HWSURFACE; isFullScreen = Data.getData("fullscreen"); if isFullScreen == "True": settings = settings | pygame.FULLSCREEN; Global.setScreenSize(infoObject.current_w, infoObject.current_h); Global.screen = pygame.display.set_mode(Global.screenSize, settings); startMenu(); initGame();
def startMenu(): # global vars GlobalVars.setActive(); # world world = World(); # camera cam = Camera(world); Render.setCamera(cam); cameraBehaviour.setCamera(cam); Global.isApplicationRunning = True; # sounds GlobalVars.getVar("sounds")['thunder'].play(); GlobalVars.getVar("sounds")['creepy'].play(); # menu behaviour menuBehaviour.setActive(True); menuBehaviour.open(); menuBehaviour.assign("play", menuBehaviour.playMenu); menuBehaviour.assign("settings", startSettings); menuBehaviour.assign("credits", startCredits); menuBehaviour.assign("quit", doQuit); menuBehaviour.assign("continue", continueGame); menuBehaviour.assign("new", startNewGame); newGame = Data.getData("isNewGame"); menuBehaviour.setNewGame(newGame);
def __init__(self, keyName): self.name = keyName self.keys = Data.getData("k_" + keyName) global events # check if the keyname already exists, if not create a new one if not self.name in events: events[self.name] = { "keys": self.keys, "functions": [] }
def __init__(self, keyName): self.name = keyName; self.keys = Data.getData("k_" + keyName); global events; # check if the keyname already exists, if not create a new one if not self.name in events: events[self.name] = { "keys" : self.keys, "functions" : [] };
def selectionItem(state): global isOpen; if state == "down": if isActive and isOpen and (usedInterface != None): currentItem = usedInterface.getEntry("currentLine"); if(currentItem == 1): # save the game Data.setData("isNewGame", False); Data.setData("lastPosition", playerBehaviour.getPlayer().getPosition()); Data.setData("lastScene", sceneBehaviour.getCurrentScene().getFileName()); Data.saveData(); print('Game saved...'); usedInterface.delete(); Global.setInterfaceOpen(False); playerBehaviour.setControlsEnabled(True); isOpen = False; characterBehaviour.stopMouvementForAllCharacters(True); else: os._exit(99);
def startGame(): inventoryBehaviour.setActive(True); # def saySomething(): # print("HELLO WORLD!!!!"); # myItem = Item("Test", "A test item", "assets/icons/inventory/test.png"); # myItem.onSelection(saySomething); # playerInventory.addItem(myItem); # playerInventory.addItem(Item("Un autre truc", "Une description un peu plus longue..", "assets/icons/inventory/test.png")); # debug active Debug.setActive(True); # action dispatcher active actiondispatcherBehaviour.setActive(True); playerBehaviour.setActive(); # load a scene for test sceneBehaviour.setActive(); # check if the user have a saved game newGame = Data.getData("isNewGame"); mainScene = None; if not (newGame): lastScene = Data.getData("lastScene"); position = Data.getData("lastPosition"); mainScene = Scene(lastScene); sceneBehaviour.setCurrentScene(mainScene); playerBehaviour.getPlayer().setPosition(position[0], position[1]); print("Last game has been loaded"); else: # start a normal game mainScene = Scene("scene2"); sceneBehaviour.setCurrentScene(mainScene); # character behaviour active characterBehaviour.setActive(True); # enable dialog system dialogBehaviour.setActive(True); # background behaviour backgroundBehaviour.setActive(True); # achievement behaviour achievementBehaviour.setActive(True); myAchievement = Achievement("Secretariat", "Vous devez aller au secretariat", lambda:print("YOUDIDIT")); achievementBehaviour.setAchievement(myAchievement); myAchievement.done(); # pause behaviour pauseBehaviour.setActive(True); Global.isApplicationRunning = True; isGameStarting = False;
def startNewGame(): print("new game"); Data.setData("isNewGame", True); isGameStarting = True; menuBehaviour.open(); startGame();
def continueGame(): Data.setData("isNewGame", False); startGame(); menuBehaviour.open();
menuBehaviour.assign("settings", startSettings); menuBehaviour.assign("credits", startCredits); menuBehaviour.assign("quit", doQuit); menuBehaviour.assign("continue", continueGame); menuBehaviour.assign("new", startNewGame); newGame = Data.getData("isNewGame"); menuBehaviour.setNewGame(newGame); #startGame(); # getting data Data.getSavedData(); infoObject = pygame.display.Info(); # restart the current application def restartApp(): os.startfile(os.path.abspath(__file__)); os._exit(99); def startApp(): # get saved data before game start screenSize = Data.getData("screenSize"); Global.setScreenSize(screenSize[0], screenSize[1]); settings = pygame.HWSURFACE;