def checkDamageCollisions(self):
        for player in Global.getGameTanks():
            player.cshape = cm.AARectShape(player.position, player.width // 2,
                                           player.height // 2)

        # for enemy in Global.objects['enemies']:
        #     enemy.cshape = cm.AARectShape(
        #         enemy.position,
        #         enemy.width // 2,
        #         enemy.height // 2
        #     )

        damage_collisions = Global.CollisionManager.objs_colliding(self)

        if damage_collisions:
            for damage_wall in Global.getGameWalls():
                if damage_wall.type == 'destroyable':
                    if damage_wall in damage_collisions:
                        damage_wall.damage(self.bullet)

            for player in Global.getGameTanks():
                if player in damage_collisions:
                    player.damage(self.bullet)

            for obj in Global.getGameObjects():
                if obj in damage_collisions:
                    obj.damage(self.bullet)
Beispiel #2
0
    def checkWithObjects(object, parent_id=None):
        try:
            collisions = Global.CollisionManager.objs_colliding(object)
        except AttributeError:
            return False

        if collisions:
            for tank in Global.getGameTanks():
                if tank in collisions:
                    if parent_id and parent_id == tank.id: continue

                    return True

            for obj in Global.getGameObjects():
                if obj in collisions:
                    return True
Beispiel #3
0
    def getBuildingByShortestDistanse(self):
        shortest_distanse = 0
        shortest_building = None

        for building in Global.getGameObjects():
            # if building.type != 5: continue
            if building.clan == self.target.clan: continue

            x1, y1 = self.target.position
            x2, y2 = building.position
            distanse = getLength(x1, y1, x2, y2)

            if not shortest_distanse or distanse < shortest_distanse:
                shortest_distanse = distanse
                shortest_building = building

        return shortest_building, shortest_distanse
Beispiel #4
0
 def getEnemyCenter(self, clan):
     for obj in Global.getGameObjects():
         if isinstance(obj, Center) and obj.clan != clan:
             return obj