Exemple #1
0
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);
Exemple #2
0
def open():
	global isOpen;
	if isActive and (usedInterface != None):
		if isOpen:
			# close it
			Global.setInterfaceOpen(False);
			usedInterface.delete();
			isOpen = False;
			playerBehaviour.setControlsEnabled(True);
			
			GlobalVars.getVar("sounds")['thunder'].stop();
			GlobalVars.getVar("sounds")['creepy'].stop();
		else:
			# open it
			if not Global.isInterfaceOpen():
				usedInterface.create();
				isOpen = True;
				Global.setInterfaceOpen(True);
				playerBehaviour.setControlsEnabled(False);
Exemple #3
0
def moveSelectionDown2(state):
	if state == "down":
		if isActive and isOpen and (usedInterface != None):

			GlobalVars.getVar("sounds")['bop'].play();

			if not isGameMenu:
				maxItems = usedInterface.getEntry("numberOfItems");
				currentLine = usedInterface.getEntry("currentLine");
				if((currentLine + 1) <= maxItems):
					usedInterface.setEntry("currentLine", currentLine+1);
				else:
					usedInterface.setEntry("currentLine", 1);
			else:
				maxItems = 2;
				currentLine = usedInterface.getEntry("currentGameLine");
				if((currentLine + 1) <= maxItems):
					usedInterface.setEntry("currentGameLine", currentLine+1);
				else:
					usedInterface.setEntry("currentGameLine", 1);
Exemple #4
0
def selectionItem(state):
	if state == "down":
		if isActive and isOpen and (usedInterface != None):

			GlobalVars.getVar("sounds")['bop'].play();

			if not isGameMenu:
				currentLine = usedInterface.getEntry("currentLine");
				currentButton = buttons[currentLine-1];

				callAssignedFunction(currentButton);
			else:
				currentLine = usedInterface.getEntry("currentGameLine");
				currentButton = gameButtons[currentLine-1];
				if(currentButton == "continue"):
					if(usedInterface.getEntry("canContinue")):
						callAssignedFunction("continue");
					else:
						print("can't continue");
				else:
					callAssignedFunction(currentButton);
Exemple #5
0
def setActive(value):
    global isActive
    global usedInterface
    isActive = value

    if value:
        keyboardInput = Keyboard("escape")
        keyboardInput.on(keyboardOpenPause)
        usedInterface = GlobalVars.getVar("pauseInterface")

        selectItem = Keyboard("action")
        selectItem.on(selectionItem)

        arrowUp = Keyboard("up")
        arrowUp.on(moveSelectionUp)
        arrowDown = Keyboard("down")
        arrowDown.on(moveSelectionDown)
def setActive(value):
	global isActive;
	global usedInterface;
	isActive = value;

	if value:
		keyboardInput = Keyboard("escape");
		keyboardInput.on(keyboardOpenPause);
		usedInterface = GlobalVars.getVar("pauseInterface");

		selectItem = Keyboard("action");
		selectItem.on(selectionItem);

		arrowUp = Keyboard("up");
		arrowUp.on(moveSelectionUp);
		arrowDown = Keyboard("down");
		arrowDown.on(moveSelectionDown);
Exemple #7
0
def setActive(value):
	global isActive;
	global isOpen;
	global usedInterface;

	isActive = value;

	usedInterface = GlobalVars.getVar("menuInterface");
	usedInterface.setOutside(outsider);

	if value:
		selectItem = Keyboard("action");
		selectItem.on(selectionItem);

		arrowUp = Keyboard("up");
		arrowUp.on(moveSelectionUp2);
		arrowDown = Keyboard("down");
		arrowDown.on(moveSelectionDown2);
		arrowLeft = Keyboard("left");
		arrowLeft.on(closeGameMenu);
Exemple #8
0
def outsider():
	GlobalVars.getVar("sounds")['thunder'].play();
def setActive():
    global transition
    transition = GlobalVars.getVar("transitionInterface")
Exemple #10
0
	def __init__(self, sceneToLoad):
		super().__init__();
		self.setType("scene");
		self.assignedElements = [];
		self.actions = [];

		self.sceneData = None;
		self.spawnPoint = None;
		self.name = "";
		self.file = sceneToLoad;

		# load a scene
		if sceneToLoad:
			f = open("assets/scenes/" + sceneToLoad + ".json", "r", encoding='utf-8');
			if f:
				self.sceneData = json.load(f);
				f.close();
		# getting scene size
		self.setSize(0, 400);

		# set the position and size of the ground
		self.groundElement = Ground();
		self.groundElement.setSize(self.size[0], self.size[0]);
		self.groundElement.setPosition(0, self.size[1]);

		mapSize = 0;

		self.name = self.sceneData['name'];

		# generate the map
		for e in self.sceneData['data']:
			if e:
				_type = e[0];
				data = e[1]
				position = [e[2], e[3]];

				element = None;
				if _type == "wall":
					element = Wall(data, position[0], position[1]);
					mapSize += 1;
				elif _type == "pickup":
					element = Pickup(data, position[0], position[1]);
				elif _type == "door":
					element = Door(data, position[0], position[1], e[4]);
					mapSize += 1;
					if len(e) == 6:
						self.actions.append(Teleport(position, e[5], [125, 0]));
				elif _type == "action":
					self.actions.append(ActionDispatcher(data, position[0], position[1]));
				elif _type == "spawn":
					self.spawnPoint = position;
				elif _type == "character":
					element = Character(e[5], e[6], e[1]);
					position = [e[2], self.getGroundPosition(element)];

					if(e[4] != None):
						dialog = Dialog(e[4]);
						dialog.assignInterface(GlobalVars.getVar("dialogInterface"));
						element.assignDialog(dialog);

				elif _type == "teleport":
					targetScene = data;
					targetPosition = [e[4], e[5]];

					self.actions.append(Teleport(position, targetScene, targetPosition));


				if element:
					self.append(element, position[0], position[1]);

		self.setSize(250 * mapSize, 400);

		# check if the scene have a background
		if 'background' in self.sceneData:
			element = Background(self.sceneData['background'], 250 * mapSize);
			self.append(element, 250 * mapSize,0);
			backgroundBehaviour.setBackground(element);


		self.assignedPlayer = None;

		Global.setTimeout(self.appendToRender, 500);
    def __init__(self, sceneToLoad):
        super().__init__()
        self.setType("scene")
        self.assignedElements = []
        self.actions = []

        self.sceneData = None
        self.spawnPoint = None
        self.name = ""
        self.file = sceneToLoad

        # load a scene
        if sceneToLoad:
            f = open("assets/scenes/" + sceneToLoad + ".json", "r", encoding="utf-8")
            if f:
                self.sceneData = json.load(f)
                f.close()
                # getting scene size
        self.setSize(0, 400)

        # set the position and size of the ground
        self.groundElement = Ground()
        self.groundElement.setSize(self.size[0], self.size[0])
        self.groundElement.setPosition(0, self.size[1])

        mapSize = 0

        self.name = self.sceneData["name"]

        # generate the map
        for e in self.sceneData["data"]:
            if e:
                _type = e[0]
                data = e[1]
                position = [e[2], e[3]]

                element = None
                if _type == "wall":
                    element = Wall(data, position[0], position[1])
                    mapSize += 1
                elif _type == "pickup":
                    element = Pickup(data, position[0], position[1])
                elif _type == "door":
                    element = Door(data, position[0], position[1], e[4])
                    mapSize += 1
                    if len(e) == 6:
                        self.actions.append(Teleport(position, e[5], [125, 0]))
                elif _type == "action":
                    self.actions.append(ActionDispatcher(data, position[0], position[1]))
                elif _type == "spawn":
                    self.spawnPoint = position
                elif _type == "character":
                    element = Character(e[5], e[6], e[1])
                    position = [e[2], self.getGroundPosition(element)]

                    if e[4] != None:
                        dialog = Dialog(e[4])
                        dialog.assignInterface(GlobalVars.getVar("dialogInterface"))
                        element.assignDialog(dialog)

                elif _type == "teleport":
                    targetScene = data
                    targetPosition = [e[4], e[5]]

                    self.actions.append(Teleport(position, targetScene, targetPosition))

                if element:
                    self.append(element, position[0], position[1])

        self.setSize(250 * mapSize, 400)

        # check if the scene have a background
        if "background" in self.sceneData:
            element = Background(self.sceneData["background"], 250 * mapSize)
            self.append(element, 250 * mapSize, 0)
            backgroundBehaviour.setBackground(element)

        self.assignedPlayer = None

        Global.setTimeout(self.appendToRender, 500)
def setActive():
	global transition;
	transition = GlobalVars.getVar("transitionInterface");