tank-game.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:pygame-robotics 作者: ioarun 项目源码 文件源码
def button(text, x, y, width, height, inactive_color, active_color, action=None):
    cur = pygame.mouse.get_pos()
    # returns a tuple (is_left?, is_center?, is_right?)
    click = pygame.mouse.get_pressed()

    if x + width > cur[0] > x and y + height > cur[1] > y:
        pygame.draw.rect(gameDisplay, active_color, (x, y, width, height))

        if click[0] == 1 and action != None:
            if action == "quit":
                pygame.quit()
                quit()
            if action == "controls":
                game_controls()
            if action == "play":
                gameLoop()
            if action == "main":
                game_intro()

    else:
        pygame.draw.rect(gameDisplay, inactive_color, (x, y, width, height))

    text_to_button(text, black, x, y, width, height)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号