def appendToRender(self): # adding all the elements to the render k = 0; for e in self.getAssignedElements(): k += 1; Render.set(e); if(k == len(self.getAssignedElements())): Global.setTimeout(self.resetRender, 1000);
def appendToRender(self): # adding all the elements to the render k = 0 for e in self.getAssignedElements(): k += 1 Render.set(e) if k == len(self.getAssignedElements()): Global.setTimeout(self.resetRender, 1000)
def editSky(self): isFlash = randint(1, 10) if (isFlash == 2): self.elements['sky'].setVisible(True) self.elements['sky_darker'].setVisible(True) if (self.callOutsider): self.callOutsider() Global.setTimeout(self.editSky2, 80)
def editSky(self): isFlash = randint(1,10); if(isFlash == 2): self.elements['sky'].setVisible(True); self.elements['sky_darker'].setVisible(True); if(self.callOutsider): self.callOutsider(); Global.setTimeout(self.editSky2, 80);
def shakeCamera(intensity, time): global isCameraShaking global shakeIntensity global savedPositionBeforeShaking if not isCameraShaking: isCameraShaking = True shakeIntensity = intensity camPosition = cameraToUse.getPosition() savedPositionBeforeShaking = [camPosition[0], camPosition[1]] Global.setInterval(camRandomPosition, 100 / intensity) Global.setTimeout(stopShaking, time)
def shakeCamera(intensity, time): global isCameraShaking; global shakeIntensity; global savedPositionBeforeShaking; if not isCameraShaking: isCameraShaking = True; shakeIntensity = intensity; camPosition = cameraToUse.getPosition(); savedPositionBeforeShaking = [camPosition[0], camPosition[1]]; Global.setInterval(camRandomPosition, 100/intensity); Global.setTimeout(stopShaking, time);
def __init__(self): super().__init__(); screenSize = Global.getScreenSize(); background = Image("assets/cinematics/test.png"); background.setSize(screenSize[0], screenSize[1]); background.setDepth(200); character = Image("assets/characterTest.png"); character.setPosition(100,100); character.setSize(100,100); character.setDepth(201); self.append(character, "character"); self.moveElementTo("character", 200,200, 2000); Global.setTimeout(self.whenArriveToEnd, 2000); self.setBackground(background);
def __init__(self): super().__init__() screenSize = Global.getScreenSize() background = Image("assets/cinematics/test.png") background.setSize(screenSize[0], screenSize[1]) background.setDepth(200) character = Image("assets/characterTest.png") character.setPosition(100, 100) character.setSize(100, 100) character.setDepth(201) self.append(character, "character") self.moveElementTo("character", 200, 200, 2000) Global.setTimeout(self.whenArriveToEnd, 2000) self.setBackground(background)
def moveElementTo(self, elementName, x, y, time, steps = 24): currentElement = self.getElementByName(elementName); if currentElement: if currentElement['element']: currentPosition = currentElement['element'].getPosition(); currentElement['isMoving'] = True; currentElement['target'] = [x, y]; currentElement['vector'] = [(x - currentPosition[0])/steps, (y - currentPosition[1])/steps]; currentElement['timer'] = Global.Interval((lambda: self.updatePosition(currentElement, x, y)), time / steps); currentElement['timeout'] = Global.setTimeout((lambda: self.destroyTimer(currentElement)), time); else: return None;
def moveElementTo(self, elementName, x, y, time, steps=24): currentElement = self.getElementByName(elementName) if currentElement: if currentElement['element']: currentPosition = currentElement['element'].getPosition() currentElement['isMoving'] = True currentElement['target'] = [x, y] currentElement['vector'] = [(x - currentPosition[0]) / steps, (y - currentPosition[1]) / steps] currentElement['timer'] = Global.Interval( (lambda: self.updatePosition(currentElement, x, y)), time / steps) currentElement['timeout'] = Global.setTimeout( (lambda: self.destroyTimer(currentElement)), time) else: return None
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 whenArriveToEnd2(self): self.moveElementTo("character", 200,0,2000); Global.setTimeout(self.stop, 2000);
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 whenArriveToEnd2(self): self.moveElementTo("character", 200, 0, 2000) Global.setTimeout(self.stop, 2000)