Exemplo n.º 1
0
def main():
    import pygame
    from colors import BLACK, WHITE
    from pygame.locals import QUIT
    from scenario import Scenario
    test = Scenario(3)
    screen = test.display.screen
    while True:
        agents = [Agent((choice(range(test.display.width)),
                         choice(range(test.display.height))),
                        0,
                        10,
                        None, test.display) for _ in range(500)]
        test.display.clear(BLACK)
        ball = choice(range(150, 774)), choice(range(150, 518))
        opponent = choice(range(150, 774)), choice(range(150, 518))
        test.draw_field("g", 0)
        #pygame.draw.circle(screen, BLUE, ball, 10)
##        pygame.draw.circle(screen, WHITE, goal, 10)
##        pygame.draw.circle(screen, RED, opponent, 10)
##        for x in range(0, test.display.width, 2 * SCALE):
##            for y in range(0, test.display.height, 2 * SCALE):
##                #print(x, y)
##                angle = f(x, y)
##                x_component, y_component = cos(angle), sin(angle)
##                test.(screen, RED, (x, y),
##                                   (x + int(x_component * SCALE * 1.5),
##                                    y + int(y_component * SCALE * 1.5)))
##                pygame.draw.aaline(screen, GREEN, (x, y),
##                                   (x + int(x_component * SCALE),
##                                    y + int(y_component * SCALE)))

        for n in range(4000):
            for event in pygame.event.get():
                if event.type == QUIT:
                    return
##                else:
##                    print(event.type)
            pygame.draw.circle(screen, WHITE, goal, 10)
            #pygame.draw.circle(screen, RED, opponent, 10)
            for agent in agents:
                agent.rotate_to(g(*agent.loc))
                agent.advance()
                agent.draw(0)
            pygame.display.flip()