Esempio n. 1
0
                         world=b2world))
    props.append(BoxProp(env, size=[3, HEIGHT], pos=[0, HEIGHT/2],
                         world=b2world))
    props.append(BoxProp(env, size=[3, HEIGHT], pos=[WIDTH, HEIGHT/2],
                         world=b2world))

    running = True
    while running:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                running = False

            if event.type in [pygame.MOUSEBUTTONDOWN, pygame.MOUSEMOTION]:
                for robot in robots:
                    robot.event_response(event)
                ball.event_response(event)

        display.fill((0, 86, 27))

        # for better code readability rend is pygame.font.Font.render
        score_image = font.render('{0} : {1}'.format(env.teamAscore,
                                                     env.teamBscore),
                                  True, (255, 255, 255))
        textpos = score_image.get_rect(centerx=WIDTH/2,
                                       centery=HEIGHT+TABLE_HEIGHT/2)
        display.blit(score_image, textpos)

        env.draw_field()
        for robot in robots:
            robot.sense()
            robot.act_handler(robot)