Ejemplo n.º 1
0
def load(tree, list):
    Nodes_button = []
    display_width = tree.objects[0].shape[0][1]
    display_height = tree.objects[0].shape[1][1]
    for button in list:
        n = button[2]
        pos = [button[0], button[1]]
        scale = button[2]
        action = button[3]
        p = coordinate(pos, scale, tree)
        Lx = tree.objects[0].shape[0][1]
        Ly = tree.objects[0].shape[1][1]
        dx = Lx / (2**n)
        dy = Ly / (2**n)
        Node = qu.Find(p, tree)
        Node.objects[0].objects.append(
            Button(action=actions[action],
                   image=pygame.image.load('drone.png')))
        button = Node.objects[0].objects[0]
        ima = button.image
        b = pygame.transform.scale(
            ima, (int(display_width / (2**n)), int(display_height / (2**n))))
        button.image = b
        Nodes_button.append(Node)
    return Nodes_button
Ejemplo n.º 2
0
carImg=pygame.transform.scale(carImg, (int(display_width/(2**n)),
        int(display_height/(2**n))))

#program.create_objects(Status)
Status.display=gameDisplay
Status.scale=[[6,28],[8,14],5]
Status.sectors=sectors



while True:
    gameDisplay.fill(black)
    mouse_poss=pygame.mouse.get_pos()
    x=mouse_poss[0]
    y=mouse_poss[1]
    b=qu.Find([x,y],sectors)
    px=int(b.objects[0].shape[0][0])
    py=int(b.objects[0].shape[1][0])
    #print(b.objects[0].shape)
#    print(px)
#    print(x)
    car(px,py)
    bu.plot_buttons(Node_buttons,sectors,gameDisplay)
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            sys.exit()
        if event.type == pygame.MOUSEBUTTONUP:
            mouse_poss = pygame.mouse.get_pos()
            x=mouse_poss[0]
            y=mouse_poss[1]
            b=qu.Find([x,y],sectors)