sp3

def x_relative_board_to_window(x):
    return x + BOARDLEFT

def y_relative_board_to_window(y):
    return y + BOARDTOP

def XRBW(x):
    return x_relative_board_to_window(x)

def YRBW(y):
    return y_relative_board_to_window(y)

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):
            if boxs[i][j]!=None:
                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):
            if boxs[i][j]!=None:
                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):  
            if boxs[i][j]!=None:
                boxs[i][j].is_revealed = True
  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值