Esempio n. 1
0
    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)
Esempio n. 2
0
    def getPlayerByShortestDistanse(self):
        shortest_distanse = 0
        shortest_player = None

        for player in Global.getGameTanks():
            if player.clan == self.target.clan: continue

            distanse = self.getDistanceByPlayer(player)

            if not shortest_distanse or distanse < shortest_distanse:
                shortest_distanse = distanse
                shortest_player = player

        return shortest_player, shortest_distanse
    def printDebugInfo(self):
        bullets = Global.getGameBullets()
        tanks = Global.getGameTanks()
        walls = Global.getGameWalls()
        CM = Global.CollisionManager
        LayersTanks = Global.Layers.tanks
        LayersWalls = Global.Layers.walls
        LayersBullets = Global.Layers.bullets
        LayersAnimations = Global.Layers.globalPanel

        print('bullets', len(bullets), 'LayersBullets',
              len(LayersBullets.children), 'LayersAnimations',
              len(LayersAnimations.children), 'CollisionManager', len(CM.objs),
              'tanks', len(tanks))
Esempio n. 4
0
    def checkDamageCollisionsOLD(self):
        damage_collisions = Global.CollisionManager.objs_colliding(self)

        if damage_collisions:
            for damage_wall in Global.getGameWalls():
                if damage_wall in damage_collisions:
                    damage_wall.damage(self.bullet)

        for player in Global.getGameTanks():

            #if parent_id == player.id: continue

            player_points = player.getPoints()
            if Collisions.check(player_points, self.bullet.position):
                player.damage(self.bullet)
Esempio n. 5
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
Esempio n. 6
0
    def getBuildingByShortestDistanse(self):
        shortest_distanse = 0
        shortest_building = None

        #for building in Global.GameObjects.getWalls():
        for building in Global.getGameTanks():
            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