Example #1
0
void fps_trombone_controls(fighter* my_fight, engine& window)
{
    trombone_manager& trombone = my_fight->trombone_manage;

    sf::Keyboard key;

    if(key.isKeyPressed(sf::Keyboard::F10))
        window.request_close();

    vec2f walk_dir = {0,0};

    if(key.isKeyPressed(sf::Keyboard::W))
        walk_dir.v[0] = -1;

    if(key.isKeyPressed(sf::Keyboard::S))
        walk_dir.v[0] = 1;

    if(key.isKeyPressed(sf::Keyboard::A))
        walk_dir.v[1] = -1;

    if(key.isKeyPressed(sf::Keyboard::D))
        walk_dir.v[1] = 1;

    bool crouching = key.isKeyPressed(sf::Keyboard::LControl);

    my_fight->crouch_tick(crouching);

    bool sprint = key.isKeyPressed(sf::Keyboard::LShift);

    if(crouching)
        sprint = false;

    if(my_fight->cube_info)
        walk_dir = my_fight->cube_info->transform_move_dir_no_rot(walk_dir);

    my_fight->walk_dir(walk_dir, sprint);

    my_fight->update_headbob_if_sprinting(sprint);

    if(once<sf::Mouse::Left>())
        trombone.play(my_fight);

    //if(once<sf::Keyboard::Z>())
    my_fight->queue_attack(attacks::TROMBONE);

    if(once<sf::Keyboard::Space>())
        my_fight->try_jump();

    ///this will probably break
    my_fight->set_look({-window.c_rot_keyboard_only.s[0], window.get_mouse_sens_adjusted_x() / 1.f, 0});


    vec2f m;
    m.v[0] = window.get_mouse_sens_adjusted_x();
    m.v[1] = window.get_mouse_sens_adjusted_y();

    float source_m_yaw = 0.0003839723;

    float yout = m.v[0] * source_m_yaw;

    ///ok, so this is essentially c_rot_keyboard_only
    ///ie local
    ///ie we give no f***s anymore because the mouse look scheme is fully consistent from local -> global
    ///ie we can ignore this, just apply the overall matrix rotation and offset to te position
    ///and etc
    my_fight->set_rot_diff({0, -yout, 0.f});

    trombone.set_active(true);
}
Example #2
0
void fps_controls(fighter* my_fight, engine& window)
{
    sf::Keyboard key;

    if(key.isKeyPressed(sf::Keyboard::F10))
        window.request_close();

    vec2f walk_dir = {0,0};

    if(key.isKeyPressed(sf::Keyboard::W))
        walk_dir.v[0] = -1;

    if(key.isKeyPressed(sf::Keyboard::S))
        walk_dir.v[0] = 1;

    if(key.isKeyPressed(sf::Keyboard::A))
        walk_dir.v[1] = -1;

    if(key.isKeyPressed(sf::Keyboard::D))
        walk_dir.v[1] = 1;

    bool crouching = key.isKeyPressed(sf::Keyboard::LControl);

    my_fight->crouch_tick(crouching);

    bool sprint = key.isKeyPressed(sf::Keyboard::LShift);

    if(crouching)
        sprint = false;

    if(my_fight->cube_info)
        walk_dir = my_fight->cube_info->transform_move_dir_no_rot(walk_dir);

    my_fight->walk_dir(walk_dir, sprint);

    my_fight->update_headbob_if_sprinting(sprint);

    if(sprint && walk_dir.v[0] < 0)
        my_fight->queue_attack(attacks::SPRINT);

    if(once<sf::Mouse::Left>())
        my_fight->queue_attack(attacks::SLASH);

    if(once<sf::Mouse::Middle>())
        my_fight->queue_attack(attacks::OVERHEAD);

    if(window.get_scrollwheel_delta() > 0.01)
        my_fight->queue_attack(attacks::STAB);

    if(once<sf::Mouse::Right>())
        my_fight->queue_attack(attacks::BLOCK);

    if(once<sf::Mouse::XButton1>())
        my_fight->queue_attack(attacks::SLASH_ALT);

    if(once<sf::Mouse::XButton2>())
        my_fight->queue_attack(attacks::OVERHEAD_ALT);

    if(once<sf::Keyboard::Z>())
        my_fight->queue_attack(attacks::TROMBONE);

    if(once<sf::Keyboard::Q>())
        my_fight->try_feint();

    if(once<sf::Keyboard::Space>())
        my_fight->try_jump();

    //window.c_rot.x = clamp(window.c_rot.x, -M_PI/2.f, M_PI/2.f);

    ///this will probably break
    my_fight->set_look({-window.c_rot_keyboard_only.s[0], window.get_mouse_sens_adjusted_x() / 1.f, 0});


    vec2f m;
    m.v[0] = window.get_mouse_sens_adjusted_x();
    m.v[1] = window.get_mouse_sens_adjusted_y();

    float source_m_yaw = 0.0003839723;

    float yout = m.v[0] * source_m_yaw;

    ///ok, so this is essentially c_rot_keyboard_only
    ///ie local
    ///ie we give no f***s anymore because the mouse look scheme is fully consistent from local -> global
    ///ie we can ignore this, just apply the overall matrix rotation and offset to te position
    ///and etc
    my_fight->set_rot_diff({0, -yout, 0.f});
}