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


Python Ship.load_file方法代码示例

本文整理汇总了Python中ship.Ship.load_file方法的典型用法代码示例。如果您正苦于以下问题:Python Ship.load_file方法的具体用法?Python Ship.load_file怎么用?Python Ship.load_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ship.Ship的用法示例。


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

示例1: on_load_ship

# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import load_file [as 别名]
 def on_load_ship(self, *args):
     self.reset_idle_time()
     self.garage_ship.kill()
     ship = Ship.load_file( "current_garage_ship.yaml", self, cocos_parent = self.root_node )
     self.block_structure = ship.block_structure
     self.refresh_garage_ship()
     ship.kill()
开发者ID:steinarvk,项目名称:blockspace,代码行数:9,代码来源:garage.py

示例2: setup_game

# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import load_file [as 别名]
    def setup_game(self, player_ship_data = None):
        self.sim = physics.PhysicsSimulator( timestep = None )
#        self.player = create_ship_thing( self, self.main_layer, (500,500), shape = "small", hp = 5 )
        if not player_ship_data:
            self.player = Ship.load_file( "current_garage_ship.yaml", self )
        else:
            self.player = Ship.load_data( player_ship_data, self )
        self.player.position = (300,300)
        self.player.invulnerable = False
        self.enemy = create_ship_thing( self, (500,500), shape = "small", hp = 10 )
        self.enemy.invulnerable = False
        self.enemy.body.angular_velocity_limit = degrees_to_radians(144*2)
        self.enemy2 = create_ship_thing( self, (0,500), shape = "small", hp = 10 )
        self.enemy2.invulnerable = False
        self.enemy2.body.angular_velocity_limit = degrees_to_radians(144*2)
        self.enemy.angle_degrees = random.random() * 360.0
        self.enemy2.angle_degrees = random.random() * 360.0
        self.batch = cocos.batch.BatchNode()
        self.main_layer.cocos_layer.add( self.batch )
        self.physics_objects = []
        self.things = []
        self.psys_managed_things = []
        for i in range(200):
            cols = "red", "purple", "grey", "blue", "green", "yellow"
            sq = create_square_thing( self, None, (100,0), None )
            sq.position = (random.random()-0.5) * 4000, (random.random()-0.5) * 4000
            sq.angle_radians = random.random() * math.pi * 2
            sq.mylabel = sq.position
            sq.velocity = (300,10)
            kw = {}
            name = "polygon_normals.4.generated"
            kw[ "size" ] = Vec2d(106.6666666,106.6666666)
            kw[ "texture_coordinates" ] = self.atlas.texcoords( name )
            kw[ "texture_size" ] = self.atlas.texsize( name )
            z = random.random() * 6.28
            r = 0.1 + random.random() * 10.0
            pos = r*math.cos(z), r*math.sin(z)
            # need to translate from pixel space
            # [0,self.
            # to
            # [-1.3333,1.3333] x [-1,1]
            p = sq.position
            p = p + self.main_layer.cocos_layer.position
            p = Vec2d(p) / Vec2d( self.window.width, self.window.height )
            p = (p * 2) - Vec2d(1,1)
            p = p * Vec2d( self.window.width / float(self.window.height), 1 ) 
            kw[ "position" ] = p
            kw[ "angle" ] = sq.angle_radians
            kw[ "colour" ] = 1.0, 0.5, 0.5, 1.0
            index = self.object_psys.add( **kw )
            self.psys_managed_things.append( (sq, index) )
            self.things.append( sq )
        def draw_psys():
            # CMSDTv
            # T = translate by self.main_layer.cocos_layer.position
            # 
            # M = v -> v - (1,1)
            # C = v -> v * (w/h, 1)
            w = float(self.window.width)
            h = float(self.window.height)
            x, y = self.main_layer.cocos_layer.position
            mat = (2.0/w,       0.0,        0.0,        (2*x/w-1),
                   0.0,         2.0/h,      0.0,        (2*y/h-1),
                   0.0,         0.0,        1.0,        0.0,
                   0.0,         0.0,        0.0,        1.0)
            self.object_psys.set_transformation_matrix( mat )
            glEnable( GL_SCISSOR_TEST )
            glScissor( 0, 0, self.window.width + 1 - self.hud_width, self.window.height )
            self.object_psys.draw()
            glDisable( GL_SCISSOR_TEST )
            s = 0.3
            sx, sy = 500 + self.sim._t * 100,200
            sx, sy = self.window.width - self.hud_width * 0.5, self.window.height - self.hud_width * 0.5
            mat = (0.0,         s*2.0/w,    0.0,        (2*sx/w-1),
                   s*2.0/h,     0,          0.0,        (2*sy/h-1),
                   0.0,         0.0,        1.0,        0.0,
                   0.0,         0.0,        0.0,        1.0)
            self.hud_psys.set_transformation_matrix( mat )
            self.hud_psys.draw()
        graphics.Layer( self.scene, cocos_layer = graphics.FunctionCocosLayer( draw_psys ) )
        self.sim.space.add_collision_handler( physics.CollisionTypes["main"], physics.CollisionTypes["bullet"], self.collide_general_with_bullet )
开发者ID:steinarvk,项目名称:blockspace,代码行数:83,代码来源:game.py


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