本文整理汇总了Python中Gui.is_won方法的典型用法代码示例。如果您正苦于以下问题:Python Gui.is_won方法的具体用法?Python Gui.is_won怎么用?Python Gui.is_won使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gui
的用法示例。
在下文中一共展示了Gui.is_won方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Control
# 需要导入模块: import Gui [as 别名]
# 或者: from Gui import is_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
#.........这里部分代码省略.........