def __init__(self): Entity.__init__(self) self.pos = Vector2d(0,0) #TODO load spikes, load random image out of a set self.anim = MW_animator.Animator(MW_xml.getChildNodeWithAttribute(MW_global.xmlwheel.loadXML("tiles.xml"), "sprite","name","spike")) self.state = "DEFAULT" self.highlight = False
def __init__(self,pos=Vector2d(0,0)): Entity.__init__(self) self.pos = pos #self.image = pygame.image.load(os.path.join("data","basic_wall.png")) self.anim = MW_animator.Animator(MW_xml.getChildNodeWithAttribute(MW_global.xmlwheel.loadXML("tiles.xml"), "sprite","name","wall")) self.state = "LIGHT" self.highlight = False
def __init__(self,exml): """pass exml node at top of graph""" if MW_xml.hasAttributes(exml, ("name","file")): imageList = exml.getAttribute("file").split(" ") self.file = imageList[random.randint(0,len(imageList))-1] self.name = exml.getAttribute("name") else: raise Exception("can not file file") MW_global.imagewheel.loadImage(self.file) self.image = MW_global.imagewheel.getImage(self.file) self.flipImage = MW_global.imagewheel.getFlipImage(self.file) self.activeNode = FrameNode(exml,1,list()) #self.activeNode = MW_global.animwheel.getAnimation(exml) self.last = 0 self.time = 0 self.dir = "RIGHT" self.state = "DEFAULT"
def __init__(self, wxml, id, createdNodeList = list()): exml = MW_xml.getChildNodeWithAttribute(wxml, "frame", "id", id) createdNodeList.append(self) #set up important data self.id = exml.getAttribute("id") if exml.hasAttribute("state"): self.state = exml.getAttribute("state") else: #print exml, " has no \"state\" attribute, setting to default DEFAULT" self.state = "DEFAULT" if exml.hasAttribute("time"): self.time = int(exml.getAttribute("time")) else: #print exml, " has no \"time\" attribute, setting to default 0" self.time = 0 if MW_xml.hasAttributes(exml, ("x","y")): self.iRect = pygame.Rect( int(exml.getAttribute("x")), int(exml.getAttribute("y")), int(exml.getAttribute("w")), int(exml.getAttribute("h")) ) else: self.iRect = pygame.Rect(0,0,0,0) print exml, " has no x y w h attributes, setting iRect2d default", self.iRect #self.dVect2d if MW_xml.hasAttributes(exml, ("dx","dy")): self.dVect2d = Vector2d(int(exml.getAttribute("dx")),int(exml.getAttribute("dy"))) else: self.dVect2d = Vector2d(0,0) #print exml, " has no dx dy attributes, setting dVect2d default", self.dVect2d #self.hRect2d if MW_xml.hasAttributes(exml, ("hx","hy","hw","hh")): self.hRect = pygame.Rect( int(exml.getAttribute("hx")), int(exml.getAttribute("hy")), int(exml.getAttribute("hw")), int(exml.getAttribute("hh")) ) else: self.hRect = pygame.Rect(0,0,self.iRect.w,self.iRect.h) #print exml, " has no hx hy hw hh attributes, setting hRect2d to default", self.hRect #set up data dict, grab data from exml dataNode = MW_xml.getChildNode(exml, "data") if dataNode: self.data = MW_xml.getAttributeMap(dataNode) else: self.data = dict() #set up next node dict, get data from xml, recursively create new ones, etc.. self.next = dict() self.nextData = dict() for e in exml.getElementsByTagName("next"): self.nextData[e.getAttribute("state")] = dict() if e.hasAttribute("time"): self.nextData[e.getAttribute("state")]["time"] = int(e.getAttribute("time")) else: self.nextData[e.getAttribute("state")]["time"] = self.time if e.hasAttribute("sound") and e.getAttribute("sound"): self.nextData[e.getAttribute("state")]["sound"] = e.getAttribute("sound") MW_global.sound.loadSound(self.nextData[e.getAttribute("state")]["sound"]) flag = True for f in createdNodeList: if f.id == e.getAttribute("id"): self.next[e.getAttribute("state")] = f flag = False break if flag: self.next[e.getAttribute("state")] = FrameNode(wxml,e.getAttribute("id"), createdNodeList)
def __init__(self): self.anim = MW_animator.Animator(MW_xml.getChildNodeWithAttribute(xml.dom.minidom.parse("anim.xml"), "sprite","name","player"))
def __init__(self,controller): self.anim = MW_animator.Animator(MW_xml.getChildNodeWithAttribute(MW_global.xmlwheel.loadXML("characters.xml"), "sprite","name","man")) PlayerEn.__init__(self,controller) self.pos = MAN_START self.respawn = MAN_START
def __init__(self): Entity.__init__(self) self.pos = Vector2d(0,0) self.id = 0 self.state = "DEFAULT" self.anim = MW_animator.Animator(MW_xml.getChildNodeWithAttribute(MW_global.xmlwheel.loadXML("tiles.xml"), "sprite","name","torch"))
def __init__(self): Entity.__init__(self) self.id = 0 self.pos = Vector2d(0,0) self.anim = MW_animator.Animator(MW_xml.getChildNodeWithAttribute(MW_global.xmlwheel.loadXML("tiles.xml"), "sprite","name","door")) self.state = "UP" #note, UP is down and DOWN is up