本文整理汇总了Python中Gui.button_collision方法的典型用法代码示例。如果您正苦于以下问题:Python Gui.button_collision方法的具体用法?Python Gui.button_collision怎么用?Python Gui.button_collision使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gui
的用法示例。
在下文中一共展示了Gui.button_collision方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Game
# 需要导入模块: import Gui [as 别名]
# 或者: from Gui import button_collision [as 别名]
#.........这里部分代码省略.........
if self.p_menu[0] != 0.0:
if self.p_menu[1] == True:
count = self.dt - self.time
else:
count = self.time - self.dt
if count < 1:
self.p_menu[0] = count
def oc_menu(self, menu):
if menu[1] == False:
self.time = self.dt + 0.1
return [0.1, True]
else:
self.time = self.dt + 1
return [0.9, False]
def draw(self):
# Background
self.active_sprites.draw(self.surf.surface)
"""
#This section is to test the Collisions visually
pygame.draw.rect(self.surf.surface, (255, 255, 255), self.player.collide_rect, 2)
for tile in self.player.collision.current_quad:
pygame.draw.rect(self.surf.surface, (255, 255, 255), tile)
"""
# Dynamic Objects
self.mobgroup.draw(self.surf.surface)
# Screen
self.screen.blit(self.surf.surface, self.surf.rect)
# Gui Menues
self.powers_gui.draw(self.screen)
if self.p_menu[0] != 0.0:
self.player_menu.draw(self.screen, self.p_menu[0])
# Mouse pointer
self.mouseover.draw(self.screen)
def user_event(self, event):
pass
def key_down(self, key):
if key in (K_w, K_UP):
self.player.arrows[0] = 1
self.player.set_timer(self.dt)
if key in (K_a, K_LEFT):
self.player.arrows[1] = 1
self.player.set_timer(self.dt)
if key in (K_s, K_DOWN):
self.player.arrows[2] = 1
self.player.set_timer(self.dt)
if key in (K_d, K_RIGHT):
self.player.arrows[3] = 1
self.player.set_timer(self.dt)
if key == K_ESCAPE:
pygame.quit()
if key == K_o:
self.p_menu = self.oc_menu(self.p_menu)
if self.p_menu[1] == True:
self.player_menu.button_color["exit"] = (0,0,0)
def key_up(self, key):
if key in (K_w, K_UP):
self.player.arrows[0] = 0
if key in (K_a, K_LEFT):
self.player.arrows[1] = 0
if key in (K_s, K_DOWN):
self.player.arrows[2] = 0
if key in (K_d, K_RIGHT):
self.player.arrows[3] = 0
def mouse_down(self, button, pos):
if self.p_menu:
if button == 1:
if self.player_menu.button_collision("exit", pos, True):
self.p_menu = self.oc_menu(self.p_menu)
def mouse_up(self, button, pos):
pass
def mouse_motion(self, buttons, pos, rel):
self.mouseover.update(pos)
self.player.rotate_player(pos, self.surf.rect.topleft)
if self.p_menu:
if self.player_menu.button_collision("exit", pos):
if self.mouseover.state == 0:
self.mouseover.state = 1
self.mouseover.setup_text(["Exit sign"])
else:
self.mouseover.state = 0
else:
self.mouseover.state = 0