Esempio n. 1
0
Entity create_testmonkey()
{
    Model * model = Model::create(check_in_pwd("mdl/monkey.dae"), true);
    Testmonkey_input * input = new Testmonkey_input;
    Spot_light * light = new Spot_light(true, glm::vec3(0.0f, 1.0f, 1.0f), true,
        glm::vec3(0.0f, 0.0f, 0.0f),
        glm::vec3(0.0f, 0.0f, 1.0f), std::cos(10.0f * M_PI / 180.0f), 90.0f,
        0.0f, 0.1f, 0.0f);
    Audio * audio = new Audio(glm::vec3(0.0f));

    Entity ent(
        model,
        input,
        nullptr, // physics
        light,
        audio);

    ent.set_pos(glm::vec3(-10.0f, 10.0f, -10.0f));
    ent.rotate_world(0.25f * M_PI, ent.up());
    ent.rotate_world(0.25f * M_PI, ent.right());

    audio->set_pos(ent.pos());

    input->signal_light_toggled().connect(sigc::track_obj(sigc::track_obj([light, audio]()
    {
        light->enabled = !light->enabled;
        audio->play_sound(check_in_pwd("sound/tack.ogg"));
    }, *light), *audio));
    Message_locator::get().add_callback("key_down", sigc::mem_fun(*input, &Testmonkey_input::key_down));

    Jukebox_locator::get().preload_sound(check_in_pwd("sound/tack.ogg"));
    audio->play_music(check_in_pwd("sound/Monkeys_Spinning_Monkeys.ogg"), 100.0f, true);

    return ent;
}
Esempio n. 2
0
Entity create_testlight()
{
    Model * model = Model::create(check_in_pwd("mdl/boring_sphere.dae"), true);
    Testlight_input * input = new Testlight_input;
    Testlight_physics * physics = new Testlight_physics;
    Point_light * light = new Point_light(true, glm::vec3(1.0f, 0.0f, 0.0f), true,
        glm::vec3(0.0f, 0.0f, 0.0f), 1.0f, 0.5f, 0.0f);
    Audio * audio = new Audio(glm::vec3(0.0f));

    Entity ent(
        model,
        input,
        physics,
        light,
        audio);

    input->signal_light_toggled().connect(sigc::track_obj(sigc::track_obj([light, audio]()
    {
        light->enabled = !light->enabled;
        audio->play_sound(check_in_pwd("sound/clickclick.ogg"));
    }, *light), *audio));
    input->signal_move_toggled().connect(sigc::mem_fun(*physics, &Testlight_physics::toggle_movement));

    Message_locator::get().add_callback("key_down", sigc::mem_fun(*input, &Testlight_input::key_down));

    Jukebox_locator::get().preload_sound(check_in_pwd("sound/clickclick.ogg"));

    return ent;
}
Esempio n. 3
0
void Weapon::play_fire_sound(Audio& audio) {
    if (!_fire_sounds.empty()) {
        if (_current_fire_sound >= _fire_sounds.size()) {
            _current_fire_sound = 0;
        }

        audio.play_sound(_fire_sounds[_current_fire_sound]);
        _current_fire_sound++;
    }
}