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


Python Object.doTurn方法代码示例

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


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

示例1: doTurn

# 需要导入模块: from objects import Object [as 别名]
# 或者: from objects.Object import doTurn [as 别名]
    def doTurn(self, game):
        # ai
        if self.ai:
            ( addedObjects0, removedObjects0, addedGfxs0 ) = self.ai.doTurn( self, game )
        else:
            ( addedObjects0, removedObjects0, addedGfxs0 ) = ([],[],[])

        if not self.orbiting and self.pulsedUntil < game.tick:
            # engine thrust
            self.xi = self.xi + self.thrust * cos( self.ori )
            self.yi = self.yi + self.thrust * sin( self.ori )

            # gouvernailstats
            self.ri = self.ri + self.rg

            # inertia controls
            self.xi = self.xi * (0.9+0.01*self.stats.mass)*self.inertiaMod #0.9
            self.yi = self.yi * (0.9+0.01*self.stats.mass)*self.inertiaMod #0.9
            self.zi = self.zi * (0.9+0.01*self.stats.mass)*self.inertiaMod #0.9
            if fabs(self.xi) < 0.05 and fabs(self.yi) < 0.05:
                self.xi = self.yi = 0

            if self.inertiaControl:
                self.ri = self.ri * 0.9 # *self.inertiaMod
                if fabs(self.ri) < 0.0005:
                    self.ri = 0

        if (not self.ai or self.ai.dockingTo) and randint( 0, config.fps*10 ) == 0:
        #    zDiff = -2 + 4*randint( 0, 1 )
            nz = randint( -5, 5 )
            can = True
            for obj in game.objects.getWithinArea( self, self.stats.maxRadius+500 ):
            #    print "s ", obj.zp <= max( self.zp, nz ), obj.zp >= min( self.zp, nz ), areOver( self, obj )
                if obj != self and obj.zp <= max( self.zp, nz ) and obj.zp >= min( self.zp, nz ) and areOver( self, obj ):
                    can = False
                    break
         #   print "switch", can, nz, obj.zp <= max( self.zp, nz ), obj.zp >= min( self.zp, nz ), areOver( self, obj )
            if can:
                self.zp = nz
                    
 
        ( addedObjects1, removedObjects1, addedGfxs1 ) = Object.doTurn( self, game )
#        if self.thrust > 0 and self.stats.engines:
#            if randint( 0, 4 ) == 0:
#                engine = choice( self.stats.engines )
#                (x,y) = (self.xp+engine[0]*cos(self.ori+engine[1]), self.yp+engine[0]*sin(self.ori+engine[1]) )
#                addedGfxs1.append( GfxExhaust( (x,y), self.zp, 0, -0.2*self.xi+(0.5-random())*0.4, -0.2*self.yi+(0.5-random())*0.4, random()*pi ) )

        if game.tick%(config.fps)==11:
            self.inNebula = False
            for obj in game.astres:
                if isinstance( obj, Nebula ) and distLowerThanObjects( self, obj, self.stats.maxRadius+obj.stats.maxRadius):
                    self.inNebula = True
                    break

        return ( addedObjects0+addedObjects1, removedObjects0+removedObjects1, addedGfxs0+addedGfxs1 )
开发者ID:xymus,项目名称:pycaptain,代码行数:58,代码来源:ships.py

示例2: doTurn

# 需要导入模块: from objects import Object [as 别名]
# 或者: from objects.Object import doTurn [as 别名]
    def doTurn( self, game ):
        (ao,ro,ag) = Object.doTurn(self, game)

        # detect hit
        for obj in game.objects.getWithinRadius( self, self.weapon.stats.projectile.explosionTriggerRange ):
            if obj.alive and obj.player != None and obj.player != self.launcher.player:
                (ao0, ro0, ag0) = explode( self, game, self.weapon.stats.projectile.explosionRange, energyDamage=self.weapon.stats.energyDamage, massDamage=self.weapon.stats.massDamage, sender=self.launcher.player, sound=ids.S_EX_FIRE )
                (ao, ro, ag) = (ao+ao0, ro+ro0, ag+ag0)

        if self.alive and self.ttl == 0:
            (ao0, ro0, ag0) = explode( self, game, self.weapon.stats.projectile.explosionRange, energyDamage=self.weapon.stats.energyDamage, massDamage=self.weapon.stats.massDamage, sender=self.launcher.player, sound=ids.S_EX_FIRE )
            (ao, ro, ag) = (ao+ao0, ro+ro0, ag+ag0)
        else:
            self.ttl = self.ttl - 1

        return (ao,ro,ag)
开发者ID:xymus,项目名称:pycaptain,代码行数:18,代码来源:weapons.py


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