def createItem(self, itemName): getInitPositionFail = [-1, -1] item_ = Object() item_.id = myFunc.getUniqueID(list(self.objList.keys())) item_.type = 'item' item_.name = '' item_.pic = itemName item_.SP = 0 item_.timeOut = round(time.time(), 3) sizeLimit = 60 im = Image.open('./static/pilot/' + item_.type + '/' + item_.pic + '.gif') newSize = myFunc.getResize([sizeLimit, sizeLimit], im.size) item_.W = newSize[0] item_.H = newSize[1] XY = myFunc.getInitPosition('auto', self.mapSize, item_, self.objList) if itemName == 'button': XY = myFunc.getInitPosition(str(self.mapSize[0]/2) + ',' + str(self.mapSize[1]/2), self.mapSize, item_, self.objList) if XY != getInitPositionFail: item_.X = XY[0] item_.Y = XY[1] item_.tX = XY[0] item_.tY = XY[1] return item_ else: return False
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 createWeapen(self, pilot): weapen = Object() weapen.id = pilot.id if pilot.weapen == 'punch': weapen.W = pilot.W / 2 weapen.H = pilot.H if pilot.dir == 'right': weapen.X = pilot.X + pilot.W / 2 + weapen.W / 2 weapen.Y = pilot.Y else: weapen.X = pilot.X - pilot.W / 2 - weapen.W / 2 weapen.Y = pilot.Y self.weapen = weapen return weapen
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