def attack(self): IO_MusicManager.getInstance().playEffect("laser") axis = 1 if self.flip == FLIP_HORIZONTAL: axis = -1 object = Stone(IO_Property(x=self.transform.x, y=self.transform.y + 12, w=16, h=16), axis=axis) self.projectiles.append(object)
def parse(self, source): xmlRoot = IO_XmlHandler.getRoot(source) xmlActivites = IO_XmlHandler.getChild(xmlRoot, "activity") for xmlActivity in xmlActivites: activiy = IO_Activity() xmlbuttons = IO_XmlHandler.getChild(xmlActivity, "button") levelcount = 1 for xmlbutton in xmlbuttons: x = float(IO_XmlHandler.getAttribute(xmlbutton, "x")) y = float(IO_XmlHandler.getAttribute(xmlbutton, "y")) w = float(IO_XmlHandler.getAttribute(xmlbutton, "w")) h = float(IO_XmlHandler.getAttribute(xmlbutton, "h")) name = IO_XmlHandler.getAttribute(xmlbutton, "name") button = None if name == "quit": button = QuitButton(IO_Property(x=x, y=y, w=w, h=h), name, activiy) elif name == "instruct": button = InstructButton(IO_Property(x=x, y=y, w=w, h=h), name, activiy) elif name == "restart": button = RestartButton(IO_Property(x=x, y=y, w=w, h=h), name, activiy) elif name == "current": button = CurrentButton(IO_Property(x=x, y=y, w=w, h=h), name, activiy) else: button = LevelButton(IO_Property(x=x, y=y, w=w, h=h), name, levelcount, activiy) levelcount += 1 activiy.buttons[name] = button activiy.activityObjects["game"] = Game.getInstance() IO_UserInterface.getInstance().activities["start"] = activiy xmlCurrent = IO_XmlHandler.getChild(xmlRoot, "current")[0] name = IO_XmlHandler.getAttribute(xmlCurrent, "name") IO_UserInterface.getInstance( ).currnetActivity = IO_UserInterface.getInstance().activities[name]
def __init__(self, x, y): super().__init__(IO_Property(x=x, y=y, w=32, h=46), name=Goal) self.atGoal = False
def __init__(self,x:int,y:int,w:float,h:float,num): super().__init__(IO_Property(x=x ,y=y, w = w, h= h),name="Spike"+str(num))
def __init__(self,x : int, y : int,w : int,h : int, num:int, force:IO_Vector = IO_Vector(y=-3)): super().__init__( IO_Property(texture=IO_TextureManager.getInstance().textureMap["obstacle"],x = x, y = y ,w = w, h = h), name="Barrier"+str(num)) self.buttons : list[Button] = [] self.force : IO_Vector = force self.startingpos = IO_Point(self.transform.x,self.transform.y) self.opentime = 40
def __init__(self,x : int, y : int,name): super().__init__(IO_Property(animation=IO_AnimationHandler.getInstance().animationMap["trigger_2"],x = x, y = y ,w = 32, h = 32),name) self.isPressed = False self.animation.pause = True
def parse(self, source): xmlRoot = IO_XmlHandler.getRoot(source) xmllevels = IO_XmlHandler.getChild(xmlRoot, "level") for xmllevel in xmllevels: level = Level() name = IO_XmlHandler.getAttribute(xmllevel, "name") map = IO_XmlHandler.getAttribute(xmllevel, "map") self.levelMap[name] = level level.name = name level.map = IO_MapManager.getInstance().maps[map] level.wall = IO_MapManager.getInstance().maps[map].layers["wall"] xmlcharacters = IO_XmlHandler.getChild(xmllevel, "character")[0] for xmlcharacter in xmlcharacters: #print(xmlcharacter.tag) #xmlActor = IO_XmlHandler.getChild(xmlcharacter,xmlcharacter.tag)[0] x = float(IO_XmlHandler.getAttribute(xmlcharacter, "x")) y = float(IO_XmlHandler.getAttribute(xmlcharacter, "y")) w = float(IO_XmlHandler.getAttribute(xmlcharacter, "w")) h = float(IO_XmlHandler.getAttribute(xmlcharacter, "h")) actor = None if xmlcharacter.tag == "Dude": actor = level.dude = Dude( IO_Property(animation=IO_AnimationHandler.getInstance( ).animationMap[xmlcharacter.tag + "_Monster_Idle_4"], x=x, y=y, w=w, h=h)) if xmlcharacter.tag == "Owlet": actor = level.owlet = Owlet( IO_Property(animation=IO_AnimationHandler.getInstance( ).animationMap[xmlcharacter.tag + "_Monster_Idle_4"], x=x, y=y, w=w, h=h)) if xmlcharacter.tag == "Pink": actor = level.pink = Pink( IO_Property(animation=IO_AnimationHandler.getInstance( ).animationMap[xmlcharacter.tag + "_Monster_Idle_4"], x=x, y=y, w=w, h=h)) level.characters[xmlcharacter.tag] = actor xmlBarriers = IO_XmlHandler.getChild(xmllevel, "barrier") num = 0 for xmlBarrier in xmlBarriers: x = float(IO_XmlHandler.getAttribute(xmlBarrier, "x")) y = float(IO_XmlHandler.getAttribute(xmlBarrier, "y")) w = float(IO_XmlHandler.getAttribute(xmlBarrier, "w")) h = float(IO_XmlHandler.getAttribute(xmlBarrier, "h")) forceX = float(IO_XmlHandler.getAttribute( xmlBarrier, "forceX")) forceY = float(IO_XmlHandler.getAttribute( xmlBarrier, "forceY")) barrier = Barrier(x=x, y=y, w=w, h=h, num=num, force=IO_Vector(x=forceX, y=forceY)) num += 1 xmlbuttons = IO_XmlHandler.getChild(xmlBarrier, "button") numb = 0 for xmlbutton in xmlbuttons: x = float(IO_XmlHandler.getAttribute(xmlbutton, "x")) y = float(IO_XmlHandler.getAttribute(xmlbutton, "y")) buttons = Button(x=x, y=y, name=str(numb)) barrier.buttons.append(buttons) numb += 1 level.barriers.append(barrier) xmlSpikes = IO_XmlHandler.getChild(xmllevel, "spike") num = 0 for xmlSpike in xmlSpikes: x = float(IO_XmlHandler.getAttribute(xmlSpike, "x")) y = float(IO_XmlHandler.getAttribute(xmlSpike, "y")) w = float(IO_XmlHandler.getAttribute(xmlSpike, "w")) h = float(IO_XmlHandler.getAttribute(xmlSpike, "h")) spike = Spike(x=x, y=y, w=w, h=h, num=str(num)) level.spikes.append(spike) num += 1 xmlGoal = IO_XmlHandler.getChild(xmllevel, "goal")[0] x = float(IO_XmlHandler.getAttribute(xmlGoal, "x")) y = float(IO_XmlHandler.getAttribute(xmlGoal, "y")) level.goal = Goal(x=x, y=y)