本文整理匯總了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