当前位置: 首页>>代码示例>>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;未经允许,请勿转载。