Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 3
0
def game_loop():
    game_exit = False
    pygame.init()
    pygame.display.set_caption('Python Game')
    game_screen = pygame.display.set_mode(game_settings.SCREEN_SIZE, )
    game_map = load_pygame(game_settings.MAP_DIR)
    draw_background_with_tiled_map(game_screen, game_map)
    green_energy_img = load_alpha_image('green_energy.png')
    energy_stone = EnergyStore(green_energy_img, 'green-stone')

    green_hero_img = load_alpha_image('green_hero.png')
    graves_img = load_alpha_image('graves.png')
    green_hero = Hero(green_hero_img, graves_img, 'green-hero')
    green_hero.location = Vector2(200, 200)

    while not game_exit:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                game_exit = True

        energy_stone.render(game_screen)
        green_hero.render(game_screen)

        pygame.display.update()