當前位置: 首頁>>代碼示例>>Python>>正文


Python Gui.won方法代碼示例

本文整理匯總了Python中Gui.won方法的典型用法代碼示例。如果您正苦於以下問題:Python Gui.won方法的具體用法?Python Gui.won怎麽用?Python Gui.won使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Gui的用法示例。


在下文中一共展示了Gui.won方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Control

# 需要導入模塊: import Gui [as 別名]
# 或者: from Gui import won [as 別名]
class Control(object):

    #Konstruktor
    def __init__(self):
        self.turn = 0

    #Extra Initialisierungsfunktion
    def on_init(self):
        pygame.init()
        self._running = True

        #instantinate gui
        self.g = Gui()

        #instantinate player
        self.p = []
        for i in range(2):
            self.p.append(Player(i))

        self.turn = 0


    #Hauptfunktion (der Anfang & das Ende)
    def on_execute(self):
        #fuehrt on_init() aus und prueft fehler
        if (self.on_init() == False):
            self._running = False

        self.render()
        #Laeuft von Anfang bis Objektende
        while (self._running):
            for event in pygame.event.get():
                self.on_event(event)

            #Spielroutine
            #self.on_loop()
            #Renderroutine
            self.render()

        self.on_cleanup()

    #Verarbeitet Spielerevent
    def on_event(self, event):
        #escape key
        if event.type == KEYDOWN and event.key == 27:
            self._running = False
        elif event.type == MOUSEBUTTONDOWN:
            #left
            if event.button == 1:
                self.on_lbutton_down(event)


    #Spielroutine
    def on_loop(self):
        pass

    #Renderroutine
    def render(self):
        self.g.render()
        pygame.display.update()


    #Aufraeumen (nur ganz am Ende)
    def on_cleanup(self):
        pygame.quit()

    def gameturn(self, address):
        a, b, c, d = address
        print "------------------------------------------------------------"
        print "f[",a,"][",b,"].b[",c,"][",d,"]"
        print "f[",a,"][",b,"].b[",c,"][",d,"].top:", self.g.f[a][b].b[c][d].top
        print "f[",a,"][",b,"].b[",c,"][",d,"].left:", self.g.f[a][b].b[c][d].left
        #clicked field
        cf = self.g.f[a][b]
        #clicked box
        cb = self.g.f[a][b].b[c][d]
        #current player
        cp = self.p[self.turn%2].p_id + 1
        #next field
        nf = self.g.f[c][d]


        print "Bide:", cf.bide
        if cf.bide:
            #fill empty box with current player
            if (cb.state == 0):
                cb.state = cp

            #if field is not won yet, set winner
            if cf.state == 0:
                winner = cf.is_won(c, d)
                cf.state = winner
                ##check if the game is won
                #gamewinner = self.g.is_won(a, b)

            #after first turn
            if self.turn == 0:
                for a in range(3):
                    for b in range(3):
                        self.g.f[a][b].bide = False
#.........這裏部分代碼省略.........
開發者ID:1uk,項目名稱:3tsqd,代碼行數:103,代碼來源:Control.py


注:本文中的Gui.won方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。