| 44 | } |
| 45 | |
| 46 | void MovementController::Tick( const KeyboardState& keyboard_state ) |
| 47 | { |
| 48 | const Time new_tick= Time::CurrentTime(); |
| 49 | |
| 50 | const float dt_s= ( new_tick - prev_calc_tick_ ).ToSeconds(); |
| 51 | |
| 52 | prev_calc_tick_= new_tick; |
| 53 | |
| 54 | auto key_pressed= |
| 55 | [&]( const char* const key_setting_name ) |
| 56 | { |
| 57 | using KeyCode= SystemEvent::KeyEvent::KeyCode; |
| 58 | const KeyCode key= static_cast<KeyCode>( settings_.GetInt( key_setting_name ) ); |
| 59 | if( key > KeyCode::Unknown && key < KeyCode::KeyCount ) |
| 60 | return keyboard_state[ static_cast<unsigned int>( key ) ]; |
| 61 | return false; |
| 62 | }; |
| 63 | |
| 64 | m_Vec3 rotate_vec( 0.0f ,0.0f, 0.0f ); |
| 65 | if( key_pressed( SettingsKeys::key_turn_left ) ) rotate_vec.z+= +1.0f; |
| 66 | if( key_pressed( SettingsKeys::key_turn_right ) ) rotate_vec.z+= -1.0f; |
| 67 | if( key_pressed( SettingsKeys::key_look_up ) ) rotate_vec.x+= +1.0f; |
| 68 | if( key_pressed( SettingsKeys::key_look_down ) ) rotate_vec.x+= -1.0f; |
| 69 | |
| 70 | const float rot_speed= 1.75f; |
| 71 | angle_+= dt_s * rot_speed * rotate_vec; |
| 72 | |
| 73 | ClipCameraAngles(); |
| 74 | |
| 75 | jump_pressed_= key_pressed( SettingsKeys::key_jump ); |
| 76 | } |
| 77 | |
| 78 | void MovementController::SetSpeed( const float speed ) |
| 79 | { |