Пример #1
0
def draw_screen(showfps):
    scale = 0
    if assets.sheight != assets.sh or assets.swidth != assets.sw: scale = 1
    scaled = pygame.screen
    top = scaled.subsurface([[0, 0], [assets.sw, assets.sh]])
    bottom = top
    mode, dim = settings.screen_format(assets)
    if mode == "two_screens" or mode == "horizontal" or mode == "show_one" or mode == "small_bottom_screen":
        bottom = scaled.subsurface([[0, assets.sh], [assets.sw, assets.sh]])
    pygame.real_screen.fill([10, 10, 10])

    def draw_segment(dest, surf, pos, size):
        rp = [pos[0] * assets.swidth, pos[1] * assets.sheight]
        rs = [size[0] * assets.swidth, size[1] * assets.sheight]
        surf = fit(surf, rs)
        dest.blit(surf, rp)

    if dim["top"]:
        draw_segment(pygame.real_screen, top, dim["top"][0], dim["top"][1])
    if dim["bottom"]:
        draw_segment(pygame.real_screen, bottom, dim["bottom"][0],
                     dim["bottom"][1])
    if showfps:
        pygame.real_screen.blit(
            assets.get_font("nt").render(str(assets.clock.get_fps()), 1,
                                         [100, 180, 200]),
            [0, pygame.real_screen.get_height() - 12])
    pygame.display.flip()
Пример #2
0
def scale_relative_click(pos,rel):
    mode,dim = settings.screen_format(assets)
    def col(pp,ss):
        if pos[0]>=pp[0] and pos[0]<=pp[0]+ss[0]\
            and pos[1]>=pp[1] and pos[1]<=pp[1]+ss[1]:
            x = rel[0]/float(ss[0])*assets.sw
            y = rel[1]/float(ss[1])*assets.sh
            return [x,y]
    if dim["top"]:
        r = col(*dim["top"][2:])
        if r:
            return r
    if dim["bottom"]:
        r = col(*dim["bottom"][2:])
        if r:
            return r
    return rel
Пример #3
0
def scale_relative_click(pos, rel):
    mode, dim = settings.screen_format(assets)

    def col(pp, ss):
        if pos[0]>=pp[0] and pos[0]<=pp[0]+ss[0]\
            and pos[1]>=pp[1] and pos[1]<=pp[1]+ss[1]:
            x = rel[0] / float(ss[0]) * assets.sw
            y = rel[1] / float(ss[1]) * assets.sh
            return [x, y]

    if dim["top"]:
        r = col(*dim["top"][2:])
        if r:
            return r
    if dim["bottom"]:
        r = col(*dim["bottom"][2:])
        if r:
            return r
    return rel
Пример #4
0
def translate_click(pos):
    mode,dim = settings.screen_format(assets)
    def col(pp,ss):
        if pos[0]>=pp[0] and pos[0]<=pp[0]+ss[0]\
            and pos[1]>=pp[1] and pos[1]<=pp[1]+ss[1]:
            x = pos[0]-pp[0]
            x = x/float(ss[0])*assets.sw
            y = pos[1]-pp[1]
            y = y/float(ss[1])*assets.sh
            return [int(x),int(y)]
    if dim["top"]:
        r = col(*dim["top"][2:])
        if r:
            return r
    if dim["bottom"]:
        r = col(*dim["bottom"][2:])
        if r:
            r[1]+=assets.sh
            return r
    return [-100000,-100000]
Пример #5
0
def draw_screen(showfps):
    scale = 0
    if assets.sheight!=assets.sh or assets.swidth!=assets.sw: scale = 1
    scaled = pygame.screen
    top = scaled.subsurface([[0,0],[assets.sw,assets.sh]])
    bottom = top
    mode,dim = settings.screen_format(assets)
    if mode == "two_screens" or mode == "horizontal" or mode == "show_one" or mode == "small_bottom_screen":
        bottom = scaled.subsurface([[0,assets.sh],[assets.sw,assets.sh]])
    pygame.real_screen.fill([10,10,10])
    def draw_segment(dest,surf,pos,size):
        rp = [pos[0]*assets.swidth,pos[1]*assets.sheight]
        rs = [size[0]*assets.swidth,size[1]*assets.sheight]
        surf = fit(surf,rs)
        dest.blit(surf,rp)
    if dim["top"]:
        draw_segment(pygame.real_screen,top,dim["top"][0],dim["top"][1])
    if dim["bottom"]:
        draw_segment(pygame.real_screen,bottom,dim["bottom"][0],dim["bottom"][1])
    if showfps:
        pygame.real_screen.blit(assets.get_font("nt").render(str(assets.clock.get_fps()),1,[100,180,200]),[0,pygame.real_screen.get_height()-12])
    pygame.display.flip()
Пример #6
0
def translate_click(pos):
    mode, dim = settings.screen_format(assets)

    def col(pp, ss):
        if pos[0]>=pp[0] and pos[0]<=pp[0]+ss[0]\
            and pos[1]>=pp[1] and pos[1]<=pp[1]+ss[1]:
            x = pos[0] - pp[0]
            x = x / float(ss[0]) * assets.sw
            y = pos[1] - pp[1]
            y = y / float(ss[1]) * assets.sh
            return [int(x), int(y)]

    if dim["top"]:
        r = col(*dim["top"][2:])
        if r:
            return r
    if dim["bottom"]:
        r = col(*dim["bottom"][2:])
        if r:
            r[1] += assets.sh
            return r
    return [-100000, -100000]