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


Python Team.set_opponent_team方法代码示例

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


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

示例1: Profile

# 需要导入模块: from team import Team [as 别名]
# 或者: from team.Team import set_opponent_team [as 别名]
class Profile():
    
    def __init__(self, is_player2_present=False,
                 is_player1_ai=False,
                 is_player2_ai=False,
                 player1_team="Green",
                 player2_team="Red",
                 greenteamsize=8,
                 redteamsize=8,
                 debris_min=6,
                 debris_max=20,
                 draw_planet=False,
                 name=""):
        self.p2 = is_player2_present
        self.p1_ai = is_player1_ai
        self.p2_ai = is_player2_ai
        self.p1_team = player1_team
        self.p2_team = player2_team
        
        mingreen = int(self.p1_team == "Green") + int(self.p2_team == "Green" and self.p2)
        minred = int(self.p1_team == "Red") + int(self.p2_team == "Red" and self.p2)
        self.green = max(mingreen, greenteamsize)
        self.red = max(minred, redteamsize)
        self.hellmin = debris_min
        self.hellmax = debris_max
        self.draw_planet = draw_planet
        self.name = name
        
        self.ERAD = 1000
        self.MAXRAD = 1700
        self.ORBHEIGHT = 350
        
    def game_init(self):
        pygame.init()
    
        self.PROFILESTEP = False
        
        self.UPDAE_GAME = pygame.USEREVENT + 1
        pygame.time.set_timer(self.UPDAE_GAME, GAME_SPEED)
        
        self.screen = pygame.display.set_mode(display)
        
        if self.p2:
            self.bg1 = Surface((wwidth, wheight/2))
            self.bg2 = Surface((wwidth, wheight/2))
            self.cam2 = camera.Camera(self.bg2, first_in_order=False)
            self.bgs = (self.bg1, self.bg2)
        else:
            self.bg1 = Surface((wwidth, wheight))
            self.bgs = (self.bg1,)
        self.cam1 = camera.Camera(self.bg1)
        
        if self.name == "":
            pygame.display.set_caption("Orbotor")
        else:
            pygame.display.set_caption("Orbotor - %s" % self.name)
            
        self.pl = planet.Planet(self.bgs, self.ERAD, self.MAXRAD, "planet.png" if self.draw_planet else None)
        GCD_Singleton.set_planet(self.pl)
        
        self.soundsys = SoundSystem_Singleton
        
        self.spawn = (self.ERAD+self.ORBHEIGHT, 0)
        self.team1 = Team("Green", "#009900", self.green, self.spawn, self.pl)
        self.team2 = Team("Red", "#880000", self.red, self.spawn, self.pl)
        self.team1.set_opponent_team(self.team2)
        self.team2.set_opponent_team(self.team1)
        self.hell = HellDebrisCollection(self.spawn, self.pl, self.hellmin, self.hellmax)
        
        if self.p1_team == "Green":
            self.player1 = self.team1.guys[0]
            if self.p2:
                if self.p2_team == "Green":
                    self.player2 = self.team1.guys[1]
                elif self.p2_team == "Red":
                    self.player2 = self.team2.guys[0]
                else:
                    raise Exception("unknown team for p2: %s" % self.p2_team)
        elif self.p1_team == "Red":
            self.player1 = team2.guys[0]
            if self.p2:
                if self.p2_team == "Green":
                    self.player2 = self.team1.guys[0]
                elif self.p2_team == "Red":
                    self.player2 = self.team2.guys[1]
                else:
                    raise Exception("unknown team for p2: %s" % self.p2_team)
        else:
            raise Exception("unknown team for p1: %s" % self.p1_team)
        self.player1.is_ai = self.p1_ai
        
        if self.p1_ai:
            self.player1.set_name("[bot] %s" % p1_name)
        else:
            self.player1.set_name("%s" % p1_name)
            
        if self.p2:
            self.player2.is_ai = self.p2_ai
            if self.p2_ai:
                self.player2.set_name("[bot] %s" % p2_name)
#.........这里部分代码省略.........
开发者ID:mr555ru,项目名称:orbotor,代码行数:103,代码来源:gameprofile.py


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