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


Python entities.Entity类代码示例

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


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

示例1: __init__

    def __init__(self, map, position):

        print "New player"

        Entity.__init__(self)
        self._lock = None
        self._phys = Verlet(position)
        self._phys.setDamping((0.02, 0.02, 0.0002))
        self._phys.setGravity((0, 0, -0.00006))

        self._on_floor = False
        self._speed = 0

        self._map = map
        self._heading = 0
        self.reset()

        r = self._radius = 0.1

        self.setBounds(((-r, -r, -r), (r, r, r)))  # entity stuff
        Entity.moveTo(self, position)  # keep the entity updated

        self._scaling = T.scale_matrix(self._radius)

        self._last_pos = N.array((0, 0, 0), dtype="f")

        self._graphics = R.loadObject("sphere.obj", "diffuse")
开发者ID:Gato-X,项目名称:NotYourData,代码行数:27,代码来源:player.py

示例2: __init__

    def __init__(self, scene, pos, dest, router):
        Entity.__init__(self)
        self._destroyed = False
        self._closing = False
        self._target_reached = False

        self._scene = scene
        self._map = scene.getMap()

        self._path = None

        self._dying_t = 0
        self._spin = 0

        self.moveTo(pos)

        self._scale = 1.0
        self._graphics = R.loadObject("enemy.obj","diffuse")
        self._orient_m= T.identity_matrix()

        self._xform_m = N.dot(T.rotation_matrix(math.pi/2,(0,0,1)),T.scale_matrix(self._scale))

        bounds = self._graphics.getObj().getBounds()

        router.requestJob(pos, dest, Enemy.OnRouteObtained, self)

        Entity.setBounds(self,bounds * self._scale)
        self._destroyed = False
        self._old_time = 0

        self._old_pos = None # At t-1
        self._old_pos2 = None # At t-2

        self._hc = HeadingController()
开发者ID:Gato-X,项目名称:NotYourData,代码行数:34,代码来源:enemy.py

示例3: __init__

    def __init__(self, pos=Vector(0, 0), rot=0.0):
        """Creates a new Ship

        Args:
            pos: the position of the ship
            rot: the rotation of the ship

        Returns:
            a new Ship instance
        """

        # Get the initial direction of the ship using the rotation
        direction = Vector(cos(radians(rot)), sin(radians(rot)))

        # Initially, the ship isn't moving
        self._movement = Vector.zero()

        # Initialize bullet list
        self.bullets = []
        self._last_shoot = self._shoot_delay
        self._last_teleport = self._teleport_delay
        self.teleport_up = True
        self.effect_player = EffectPlayer.instance()
        Entity.__init__(self, (20, 0, -30, 20, -30, -20), direction,
                        lin_speed=1.0, rot_speed=2.0, pos=pos, rot=rot,
                        scale=0.5)
开发者ID:Cheeser12,项目名称:pysteroids,代码行数:26,代码来源:player.py

示例4: test_23_power

 def test_23_power(self):
     tl = Entity('POWER-0', EntityType.find(100), 'Power plug')
     tl.assigned_id = 1
     tl.last_checkin = time.time() - 3600 # one hour before
     tl.save()
     self.printall()
     print tl
开发者ID:rycus86,项目名称:IntelliHomeControl-py,代码行数:7,代码来源:tentity.py

示例5: test_onestop_notimplemented

 def test_onestop_notimplemented(self):
   # requires geohash() to be implemented.
   entity = Entity(**self.expect)
   with self.assertRaises(NotImplementedError):
     entity.id()
   with self.assertRaises(NotImplementedError):
     entity.onestop()
开发者ID:srthurman,项目名称:transitland-python-client,代码行数:7,代码来源:test_entity.py

示例6: __init__

    def __init__(self, scene, pos):
        Entity.__init__(self)
        self._destroyed = False
        self._closing = False

        self._scene = scene

        self.moveTo(pos)

        self._graphics = R.loadObject("targetpt.obj","diffuse")
        self._beacon = R.loadObject("beacon.obj","glow")

        self._anim_m = T.identity_matrix()
        self._rot= T.quaternion_about_axis(0, (0,0,1))
        self._rot_speed = T.quaternion_about_axis(0.01, (0,0,1))

        self._scale = 0.15

        self.moveTo(self.getPosition() + (0,0,-0.3))

        self._scale_m = T.scale_matrix(self._scale)

        bounds = self._graphics.getObj().getBounds() * self._scale

        Entity.setBounds(self,bounds)
开发者ID:Gato-X,项目名称:NotYourData,代码行数:25,代码来源:targetpoint.py

示例7: update

    def update(self, time):
        if self._destroyed:
            return False

        if self._t0 is None:
           self._t0 = time

        if self._follow is not None and not self._follow.closing() :

            d = self._follow._pos - self._pos

            T.unit_vector(d,d)

            self._dir = self._dir * (1-self._thrust) + d * self._thrust

            if time - self._t0 > 3000 or self._follow._destroyed:
                print "Not following anymore"

                self._follow = None

            Entity.moveTo(self, self._pos + self._dir * self._speed) # also updates _pos
        else:
            # too simple to use Verlet
            Entity.moveTo(self, self._pos + self._dir * self._speed) # also updates _pos
            self._dir += self._gravity

        self._xform = mmult(self._pos_m,self._scaling_m, T.quaternion_matrix(self._rotation))
        self._rotation = T.quaternion_multiply(self._d_rotation, self._rotation)

        # hit the floor
        if self._map(self._pos[0], self._pos[1], False) > self._pos[2]:
            self.explode()
            return False # tell the scene the missile is toast

        return True
开发者ID:Gato-X,项目名称:NotYourData,代码行数:35,代码来源:missile.py

示例8: test_merge_rels

 def test_merge_rels(self):
   entity1 = Entity(serves=['a','b','c'])
   entity2 = Entity(serves=['c','d','e'])
   entity1.merge(entity2)
   serves = ['a', 'b', 'c', 'd', 'e']
   assert len(entity1.data['serves']) == 5
   for i in serves:
     assert i in entity1.data['serves']
开发者ID:srthurman,项目名称:transitland-python-client,代码行数:8,代码来源:test_entity.py

示例9: __init__

    def __init__(self, poi_type, red, black):
        Entity.__init__(self, poi_type, red, black)
        self.width = 90
        self.height = 90
        self.offsetRed = self.height/2
        self.offsetBlack = self.width/2

        self.conceal()
开发者ID:marlusclayton,项目名称:flashpoint,代码行数:8,代码来源:pois.py

示例10: test_merge_existing_pass

 def test_merge_existing_pass(self):
   entity1 = Entity()
   entity1.add_identifier('abc')
   entity2 = Entity()
   entity2.add_identifier('abc')
   entity1.merge(entity2)
   assert len(entity1.identifiers()) == 1
   assert entity1.identifiers()[0] == 'abc'
开发者ID:srthurman,项目名称:transitland-python-client,代码行数:8,代码来源:test_entity.py

示例11: test_add_identifier

 def test_add_identifier(self):
   data = ['abc', 'def']
   entity = Entity()
   for k in data:
     entity.add_identifier(k)
   assert len(entity.identifiers()) == 2
   for i in entity.identifiers():
     assert i in data
开发者ID:srthurman,项目名称:transitland-python-client,代码行数:8,代码来源:test_entity.py

示例12: test_pclink

 def test_pclink(self):
   entity1 = Entity()
   entity2 = Entity()
   assert len(entity1.children) == 0
   assert len(entity2.parents) == 0
   entity1.pclink(entity1, entity2)
   assert len(entity1.children) == 1
   assert len(entity2.parents) == 1
开发者ID:srthurman,项目名称:transitland-python-client,代码行数:8,代码来源:test_entity.py

示例13: __init__

 def __init__(self, door_type, red, black, red_link, black_link):
     Entity.__init__(self, door_type, red, black)
     self.red_link = red_link
     self.black_link = black_link
     self.key = "door-{}-{}-{}-{}".format(red, black, red_link, black_link)
     self.width = 100
     self.height = 100
     self.set_offset()
     self.close()
开发者ID:marlusclayton,项目名称:flashpoint,代码行数:9,代码来源:doors.py

示例14: create_match

 def create_match(self):
     self.width = random.randint(25, 50)
     self.height = random.randint(25, 50)
     self.tiles = {}
     for y in range(self.height):
         for x in range(self.width):
             self.tiles[(x, y)] = 'grass'
     test_entity = Entity('test_ape', self, (0, 0), Item('bomb', self))
     test_entity.use()
开发者ID:PhelanBavaria,项目名称:BomberApe,代码行数:9,代码来源:main.py

示例15: test_merge

 def test_merge(self):
   data = ['abc', 'def']
   entity1 = Entity()
   entity1.add_identifier('abc')
   entity2 = Entity()
   entity2.add_identifier('def')
   entity1.merge(entity2)
   assert len(entity1.identifiers()) == 2
   for i in entity1.identifiers():
     assert i in data
开发者ID:srthurman,项目名称:transitland-python-client,代码行数:10,代码来源:test_entity.py


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