本文整理汇总了Python中Gui.get_rect_adress方法的典型用法代码示例。如果您正苦于以下问题:Python Gui.get_rect_adress方法的具体用法?Python Gui.get_rect_adress怎么用?Python Gui.get_rect_adress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gui
的用法示例。
在下文中一共展示了Gui.get_rect_adress方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Control
# 需要导入模块: import Gui [as 别名]
# 或者: from Gui import get_rect_adress [as 别名]
#.........这里部分代码省略.........
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
#current field stop biding
cf.bide = False
#next field start biding
nf.bide = True
print "Next Field: f.[",c,"][",d,"]"
#turn over
self.turn += 1
self.player = self.turn % 2 + 1
gamewinner = self.g.is_won(a,b)
if gamewinner:
nf.bide = False
self.g.won(gamewinner)
############
## Events ##
############
#siehe pygame.org/docs/ref/event.html
#------------------------------------
def on_lbutton_down(self, event):
#if a box is clicked
if (self.g.get_rect_adress(event.pos[0], event.pos[1])):
self.gameturn(self.g.get_rect_adress(event.pos[0], event.pos[1]))