当前位置: 首页>>代码示例>>Python>>正文


Python Gui.button_collision方法代码示例

本文整理汇总了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
开发者ID:Exodus111,项目名称:Infinite-Adventure,代码行数:104,代码来源:Game.py


注:本文中的Gui.button_collision方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。