예제 #1
0
tagBack = False
#pygame.time.set_timer(TAGEVENT, 1000)
while not done:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done = True
        #if event.type == TAGEVENT:
        #for enemy in enemyList:
        #enemy.calculateNeighbors()

        #tagBack = False
        #TAGEVENT = pygame.USEREVENT
        #pygame.time.set_timer(TAGEVENT, 1000)

    screen.fill((Constants.BACKGROUND_COLOR))

    player.update(Vector(Constants.WORLD_WIDTH, Constants.WORLD_HEIGHT))
    player.draw(screen)

    for sheep in enemyList:
        #enemy.update(player, Vector(Constants.WORLD_WIDTH, Constants.WORLD_HEIGHT))
        #enemy.draw(screen, player)
        sheep.update(player,
                     Vector(Constants.WORLD_WIDTH, Constants.WORLD_HEIGHT))
        sheep.draw(screen, player)
        #if enemy.noTagBacks and not tagBack:
        #    tagBack = True
        #pygame.time.set_timer(TAGEVENT, 1000)

    pygame.display.flip()
    clock.tick(Constants.FRAME_RATE)
예제 #2
0
            if event.key == pygame.K_a:
                graph.searchType = SearchType.A_STAR
            elif event.key == pygame.K_s:
                graph.searchType = SearchType.BEST_FIRST
            elif event.key == pygame.K_d:
                graph.searchType = SearchType.DJIKSTRA
            elif event.key == pygame.K_f:
                graph.searchType = SearchType.BREADTH_FIRST

    # Update the agents onscreen
    # dog.update(bounds, graph, herd, Constants.GATES)
    dog.update(graph, sheep)
    for sheep in herd:
        # sheep.update(bounds, graph, dog, herd, Constants.GATES)
        sheep.update(dog, herd, graph.obstacles)

    # Draw the agents onscreen
    graph.draw(screen)
    dog.draw(screen)
    for sheep in herd:
        sheep.draw(screen, dog)

    # Double buffer
    pygame.display.flip()

    # Limit to 60 FPS
    clock.tick(Constants.FRAME_RATE)

# Quit
pygame.quit()