mp3

来源:互联网 发布:最近好看的网络剧 编辑:程序博客网 时间:2024/04/28 07:35

def shuffle_boxs_color(boxs):
    global ALLCOLORS
    num_colors_need = NUMBOXHORIZONTAL * NUMBOXVERTIVAL / 2
    assert num_colors_need == NUMBOXHORIZONTAL * NUMBOXVERTIVAL / 2.0
    colors = ALLCOLORS[:]
    random.shuffle(colors)
    colors = colors[:num_colors_need]
    colors = colors * 2
    random.shuffle(colors)
    for i in range(NUMBOXHORIZONTAL):
        for j in range(NUMBOXVERTIVAL):
            boxs[i][j].color = colors[0]
            boxs[i][j].surf.fill(colors[0])
            del colors[0]

def get_box_pixel_topleft(boxs,mousex,mousey):
    for i in range(NUMBOXHORIZONTAL):
        for j in range(NUMBOXVERTIVAL):
            box_rect = pygame.Rect(XRBW(boxs[i][j].x),YRBW(boxs[i][j].y),BOXWIDTH,BOXHEIGHT)
            if box_rect.collidepoint(mousex,mousey):
                return box_rect.top,box_rect.left
    return None,None

def get_box_x_y(boxs,mousex,mousey):
    for i in range(NUMBOXHORIZONTAL):
        for j in range(NUMBOXVERTIVAL):
            box_rect = pygame.Rect(XRBW(boxs[i][j].x),YRBW(boxs[i][j].y),BOXWIDTH,BOXHEIGHT)
            if box_rect.collidepoint(mousex,mousey):
                return (i,j)
    return (None,None)

def anim_highlight_box(boxs,box_pixel_topleft):
    top = box_pixel_topleft[0]
    left = box_pixel_topleft[1]
    pygame.draw.rect(DISPLAYSURF, HIGHLIGHTCOLOR, (left - 5, top - 5, BOXWIDTH + 10, BOXHEIGHT + 10), 4)

def init_boxs_revealed(boxs):
    for i in range(NUMBOXHORIZONTAL):
        for j in range(NUMBOXVERTIVAL):  
            boxs[i][j].is_revealed = False

原创粉丝点击