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