def createCharacter(self, name_): getInitPositionFail = [-1, -1] character = Object() character.id = myFunc.getUniqueID(list(self.objList.keys())) character.timeOut = round(time.time(), 3) XY = myFunc.getInitPosition('auto', self.mapSize, character, self.objList) if name_ == 'zombie': character.name = '上班族殭屍' if XY != getInitPositionFail: character.type = 'enemy' character.pic = 'zombie' character.SP = random.randint(20, 100) * self.frameTime im = Image.open('./static/pilot/' + character.pic + '/right.gif') randomLimit = random.randint(80, 150) else: return False elif name_ == 'robot': character.name = '自走型殺人機械' if XY != getInitPositionFail: character.type = 'enemy' character.pic = 'robot' character.HP = 50 character.HPmax = 50 character.AT = 3 character.SP = 400 * self.frameTime im = Image.open('./static/pilot/' + character.pic + '/right.gif') randomLimit = random.randint(120, 120) else: return False elif name_ == 'pilot': character.name = str(character.id) if XY != getInitPositionFail: character.type = 'pilot' character.pic = 'slimeUnknow' character.SP = 350 * self.frameTime im = Image.open('./static/pilot/' + character.pic + '/right.gif') randomLimit = random.randint(70, 70) else: return False character.X = XY[0] character.Y = XY[1] character.tX = XY[0] character.tY = XY[1] newSize = myFunc.getResize([randomLimit, randomLimit], im.size) character.W = newSize[0] character.H = newSize[1] return character
def createMapItem(self, description): obj = Object() pic = description[0] X = int(description[1]) Y = int(description[2]) obj.type = 'mapObj' obj.id = myFunc.getUniqueID(list(self.objList.keys())) obj.name = str(obj.id) obj.X = X obj.Y = Y obj.tX = X obj.tY = Y if pic == 'bud': obj.HP = 1000 obj.W = 70 obj.H = 70 obj.pic = './static/map/obj/' + pic + '.png' return obj