Example #1
0
 def checkforTargets(self, enemy_list):
     '''Checks to see what enemy is inside of its range'''
     tList = [];
     count = 0
     for i in enemy_list: #Grabbs information from enemies within range and putts usefull information in a list, the targetable list
         # self.targeting_list = [ [0] = Name, [1] = Health, [2] = Xpos, [3] = Ypos, [4] = distance**2, [5] = position in enemy_list, [6] = distance travaled, [7] = Movement Vector]
         if twoD_math.point_distance_check(self.pos[0], self.pos[1], i.pos[0], i.pos[1]) <= self.range2:
             tList.append([i.name, i.health, i.pos[0], i.pos[1], twoD_math.point_distance_check(self.pos[0], self.pos[1], i.pos[0], i.pos[1]), count, i.DistTrav, i.movVec]);
             self.targeting_list = tList;
         else:
             self.targeting_list = tList;
         count += 1
Example #2
0
 def updateProjectiles(self, dtime, enemy_list):
     '''Updates all the projectiles the tower has shot'''
     # Controlling projectiles
     count = 0
     for i in self.projectileList:
         i.update(dtime)
         for ii in enemy_list:
             if twoD_math.point_distance_check(i.pos[0], i.pos[1], ii.pos[0], ii.pos[1]) < i.radius**2+ii.radius**2:
                 ii.health -= i.damage
                 self.projectileList = util.listPop(self.projectileList, count)
         if i.time >= 2:
             self.projectileList = util.listPop(self.projectileList, count)
         count += 1