当前位置: 首页>>代码示例>>Python>>正文


Python location.Location类代码示例

本文整理汇总了Python中bravo.location.Location的典型用法代码示例。如果您正苦于以下问题:Python Location类的具体用法?Python Location怎么用?Python Location使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Location类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestLocation

class TestLocation(unittest.TestCase):

    def setUp(self):
        self.l = Location()

    def test_trivial(self):
        pass

    def test_str(self):
        str(self.l)

    def test_save_to_packet(self):
        self.assertTrue(self.l.save_to_packet())

    def test_in_front_of(self):
        other = self.l.in_front_of(1)

        self.assertEqual(other.pos.x, 0)
        self.assertEqual(other.pos.z, 32)

    def test_in_front_of_yaw(self):
        self.l.ori = Orientation.from_degs(90, 0)
        other = self.l.in_front_of(1)

        self.assertEqual(other.pos.x, -32)
        self.assertEqual(other.pos.z, 0)
开发者ID:LucianU,项目名称:bravo,代码行数:26,代码来源:test_location.py

示例2: TestLocation

class TestLocation(unittest.TestCase):

    def setUp(self):
        self.l = Location()

    def test_trivial(self):
        pass

    def test_str(self):
        str(self.l)

    def test_clamp_stance(self):
        """
        Clamped stance should be 1.62 blocks above the current block.
        """

        self.l.pos = Position(0, 32, 0)
        self.l.clamp()
        self.assertAlmostEqual(self.l.stance, 2.62)

    def test_save_to_packet(self):
        self.assertTrue(self.l.save_to_packet())

    def test_in_front_of(self):
        other = self.l.in_front_of(1)

        self.assertEqual(other.pos.x, 0)
        self.assertEqual(other.pos.z, 32)

    def test_in_front_of_yaw(self):
        self.l.ori = Orientation.from_degs(90, 0)
        other = self.l.in_front_of(1)

        self.assertEqual(other.pos.x, -32)
        self.assertEqual(other.pos.z, 0)
开发者ID:JDShu,项目名称:bravo,代码行数:35,代码来源:test_location.py

示例3: test_perfect_diagonal_3d_negative

    def test_perfect_diagonal_3d_negative(self):
        src = Location()
        src.x, src.y, src.z = 0, 0, 0
        dest = Location()
        dest.x, dest.y, dest.z = -3, -3, -3

        coords = [(0, 0, 0), (-1, -1, -1), (-2, -2, -2), (-3, -3, -3)]
        self.assertEqual(coords, list(gen_line_simple(src, dest)))
开发者ID:dkkline,项目名称:bravo,代码行数:8,代码来源:test_geometry.py

示例4: test_perfect_diagonal_3d

    def test_perfect_diagonal_3d(self):
        src = Location()
        src.x, src.y, src.z = 0, 0, 0
        dest = Location()
        dest.x, dest.y, dest.z = 3, 3, 3

        coords = [(0, 0, 0), (1, 1, 1), (2, 2, 2), (3, 3, 3)]
        self.assertEqual(coords, list(gen_line_simple(src, dest)))
开发者ID:dkkline,项目名称:bravo,代码行数:8,代码来源:test_geometry.py

示例5: test_straight_line

    def test_straight_line(self):
        src = Location()
        src.x, src.y, src.z = 0, 0, 0
        dest = Location()
        dest.x, dest.y, dest.z = 0, 0, 3

        coords = [(0, 0, 0), (0, 0, 1), (0, 0, 2), (0, 0, 3)]
        self.assertEqual(coords, list(gen_line_simple(src, dest)))
开发者ID:dkkline,项目名称:bravo,代码行数:8,代码来源:test_geometry.py

示例6: move_to

    def move_to(self, x, z):
        """
        Move to the place.  Don't do pathfinding.

        """

        l = Location()
        l.x = x
        l.z = z

        g = self.change_movement(l, None, 3)
        self.cmd_queue.append(g)
开发者ID:Estevo-Aleixo,项目名称:minebot,代码行数:12,代码来源:mcbot.py

示例7: test_straight_line_float

    def test_straight_line_float(self):
        """
        If floating-point coordinates are used, the algorithm still considers
        only integer coordinates and outputs floored coordinates.
        """

        src = Location()
        src.x, src.y, src.z = 0, 0, 0.5
        dest = Location()
        dest.x, dest.y, dest.z = 0, 0, 3

        coords = [(0, 0, 0), (0, 0, 1), (0, 0, 2), (0, 0, 3)]
        self.assertEqual(coords, list(gen_line_simple(src, dest)))
开发者ID:dkkline,项目名称:bravo,代码行数:13,代码来源:test_geometry.py

示例8: _load_entity_from_tag

    def _load_entity_from_tag(self, tag):
        position = tag["Pos"].tags
        rotation = tag["Rotation"].tags
        location = Location()
        location.pos = Position(position[0].value, position[1].value, position[2].value)
        location.ori = Orientation.from_degs(rotation[0].value, rotation[1].value)

        location.grounded = bool(tag["OnGround"])

        entity = entities[tag["id"].value](location=location)

        self._entity_loaders[entity.name](entity, tag)

        return entity
开发者ID:Varriount,项目名称:bravo,代码行数:14,代码来源:beta.py

示例9: move_random

    def move_random(self):
        """
        Just move the bot around...

        There are no tests about the world geometry, etc
        """

        l = Location()
        
        l.x = self.location.x + 2 - random.random() * 4
        l.z = self.location.z + 2 - random.random() * 4
        
        g = self.change_movement(l, None, 5)

        self.cmd_queue.append(g)
开发者ID:Estevo-Aleixo,项目名称:minebot,代码行数:15,代码来源:mcbot.py

示例10: create_entity

    def create_entity(self, x, y, z, name, **kwargs):
        """
        Spawn an entirely new entity at the specified block coordinates.

        Handles entity registration as well as instantiation.
        """

        bigx = x // 16
        bigz = z // 16

        location = Location.at_block(x, y, z)
        entity = entities[name](eid=0, location=location, **kwargs)

        self.register_entity(entity)

        d = self.world.request_chunk(bigx, bigz)
        @d.addCallback
        def cb(chunk):
            chunk.entities.add(entity)
            log.msg("Created entity %s" % entity)
            # XXX Maybe just send the entity object to the manager instead of
            # the following?
            if hasattr(entity,'loop'):
                self.world.mob_manager.start_mob(entity)

        return entity
开发者ID:JDShu,项目名称:bravo,代码行数:26,代码来源:factory.py

示例11: OnPlayerLocationUpdate

    def OnPlayerLocationUpdate(self, packet):
        self.bot.update_location_from_packet(packet)

        print packet

        # everytime the player spawns, it must send back the location that it was given
        # this is a check for the server.  not entirely part of authentication, but
        # the bot won't run without it
        if self.confirmed_spawn == False:
            location = Location()
            location.load_from_packet(packet)
            p = location.save_to_packet()
            self.transport.write(p)
            self.confirmed_spawn = True
            self.bot.set_location(location)
            self.bot.OnReady()
开发者ID:Estevo-Aleixo,项目名称:bravo,代码行数:16,代码来源:mcprotocol.py

示例12: change_movement

    def change_movement(self, location, position, t):
        """
        give a request to the bot to move somewhere or position itself
        return a generator that will return packets so that the movement
        is smooth.  the packets will be written to the wire at regular
        intervals.  
        NOTE: wouldn't it be real nice if we implimented position as a vector?
        Would look a lot better if plugging in some real math.  splines, anyone?
        """

        this_loc = Location()

        this_loc.x = self.location.x
        this_loc.z = self.location.z

        steps = float(t) / float(self.conn.bot_tick_interval)
   
        x_origin = self.location.x
        x_offset = 0
        x_dist = location.x - self.location.x
        x_step = x_dist / steps
        
        z_origin = self.location.z
        z_offset = 0
        z_dist = location.z - self.location.z
        z_step = z_dist / steps

        arrived = False

        while arrived == False:
            if abs(x_offset) < abs(x_dist):
                x_offset += x_step
                this_loc.x = x_origin + x_offset
            else:
                arrived = True
            
            if abs(z_offset) < abs(z_dist):
                z_offset += z_step
                this_loc.z = z_origin + z_offset
                arrived = False

            self.location.x = this_loc.x
            self.location.z = this_loc.z
            
            p, l, f = self.location.build_containers()

            yield make_packet("position", position=p, flying=f)
开发者ID:Estevo-Aleixo,项目名称:minebot,代码行数:47,代码来源:mcbot.py

示例13: TestLocation

class TestLocation(unittest.TestCase):
    def setUp(self):
        self.l = Location()

    def test_trivial(self):
        pass

    def test_default_stance(self):
        self.assertEqual(self.l.stance, 1.0)

    def test_save_to_packet(self):
        self.assertTrue(self.l.save_to_packet())

    def test_distance(self):
        other = Location()
        other.x = 2
        other.y = 3
        other.z = 6
        self.assertEqual(self.l.distance(other), 7)
开发者ID:squiddy,项目名称:bravo,代码行数:19,代码来源:test_location.py

示例14: TestLocationMethods

class TestLocationMethods(unittest.TestCase):
    def setUp(self):
        self.l = Location()

    def test_trivial(self):
        pass

    def test_in_front_of(self):
        other = self.l.in_front_of(1)

        self.assertEqual(other.x, 0)
        self.assertEqual(other.z, 1)

    def test_in_front_of_yaw(self):
        self.l.yaw = 90
        other = self.l.in_front_of(1)

        self.assertEqual(other.x, -1)
        self.assertEqual(other.z, 0)

    test_in_front_of_yaw.todo = "Precision problems"
开发者ID:squiddy,项目名称:bravo,代码行数:21,代码来源:test_location.py

示例15: create_entity

    def create_entity(self, x, y, z, name, **kwargs):
        """
        Spawn an entirely new entity.

        Handles entity registration as well as instantiation.
        """

        location = Location()
        location.x = x
        location.y = y
        location.z = z
        entity = entities[name](eid=0, location=location, **kwargs)

        self.register_entity(entity)

        bigx = entity.location.x // 16
        bigz = entity.location.z // 16

        d = self.world.request_chunk(bigx, bigz)
        d.addCallback(lambda chunk: chunk.entities.add(entity))
        d.addCallback(lambda none: log.msg("Created entity %s" % entity))

        return entity
开发者ID:gr8firedragon,项目名称:bravo,代码行数:23,代码来源:beta.py


注:本文中的bravo.location.Location类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。