當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。