Пример #1
0
def random_create(world):
    from entities import Hero
    for i in range(0, 11):
        rand_x, rand_y = randint(0, game_settings.SCREEN_WIDTH), randint(
            0, game_settings.SCREEN_HEIGHT)
        hero = Hero(green_hero_img, graves_img, "green")
        hero.location = pygame.Vector2(rand_x, rand_y)
        hero.name = 'green-hero'
        world.add_entity(hero)
Пример #2
0
def create_hero(world, hero_type):
    if hero_type == 'green':
        location = get_left_random_location()
        image = green_hero_img
        hero_name = 'green-hero'
    elif hero_type == 'red':
        location = get_right_random_location()
        image = red_hero_img
        hero_name = 'red-hero'
    else:
        raise KeyError("error type")

    from entities import Hero
    hero = Hero(world, image, graves_img, hero_type)
    hero.location = location
    hero.name = hero_name
    hero.brain.set_state(HERO_STATES[0])
    world.add_entity(hero)

    return hero