Exemplo n.º 1
0
def add_link():
    pjson = json.loads(request.data)
    source = Base.find_by_id(pjson.get('source_label'), pjson.get('source'))
    if source:
        if pjson.get('rel') in Base.rels:
            res = source.create_rels(
                pjson.get('target'),
                pjson.get('target_label'),
                pjson.get('rel'))
            if res:
                return jsonify({'result': "Ok"}), 200
            else:
                return jsonify({'result': "relationship exists"}), 409
        else:
            return jsonify({'result': "relationship not allowed"}), 201
    return jsonify({'result': "Source not found"}), 404
Exemplo n.º 2
0
def game_loop():
    bird = Bird(200, 200)
    base = Base(730)
    pipes = [Pipe(600)]
    window = pygame.display.set_mode((WN_WIDTH, WN_HIGHT))
    pygame.display.set_caption('Flappy Bird')
    clock = pygame.time.Clock()
    score = 0

    run = True
    start = True
    # e = True
    while run:
        clock.tick(30)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                run = False

        keys_pressed = pygame.key.get_pressed()
        if start:
            draw_window(window, bird, base, pipes, score)
            if keys_pressed[pygame.K_SPACE]:
                bird.jump()
                start = False
        else:
            remove_pipes = []
            passed = False
            crashed = False

            if base.collide(bird):
                crashed = True
                crash(window, score)

            for pipe in pipes:
                if pipe.collide(bird):
                    crashed = True
                    crash(window, score)
                    break

                if pipe.x + pipe.PIPE_TOP.get_width() < 0:
                    remove_pipes.append(pipe)

                if not pipe.passed and pipe.x < bird.x:
                    pipe.passed = True
                    passed = True

                pipe.move()

            # in case of collision check if player wants to replay
            if crashed:
                keys_pressed = pygame.key.get_pressed()
                if keys_pressed[pygame.K_SPACE]:
                    main()

            else:
                # if the bird passed the pipe increment score and add new pipe
                if passed:
                    score += 1
                    pipes.append(Pipe(600))

                # delete pipes that are out of the screen
                for remove in remove_pipes:
                    pipes.remove(remove)

                # check if the bird hit the ground
                if bird.x + bird.img.get_height() >= 730:
                    pass

                keys_pressed = pygame.key.get_pressed()

                # jump while playing
                if keys_pressed[pygame.K_SPACE]:
                    bird.jump()

                bird.move()
                base.move()
                draw_window(window, bird, base, pipes, score)
Exemplo n.º 3
0
def components():
    return jsonify({'components': Base.find_all('Component')})
Exemplo n.º 4
0
def get_children(app_id):
    return jsonify({'parent': app_id, 'children': Base.find_children(app_id)})
Exemplo n.º 5
0
def get_applications():
    return jsonify({'applications': Base.find_all('Application')})
Exemplo n.º 6
0
def get_people():
    return jsonify({'people': Base.find_all('Person')})