| 14 | |
| 15 | |
| 16 | void Player::keyBoardInput () |
| 17 | { |
| 18 | Vector3 change; |
| 19 | float speed = 0.4; |
| 20 | if (sf::Keyboard::isKeyPressed(sf::Keyboard::LControl)) |
| 21 | { |
| 22 | speed *= 3; |
| 23 | } |
| 24 | |
| 25 | if(m_isInLiquid) speed /= 1.5; |
| 26 | |
| 27 | float yaw = glm::radians(rotation.y); |
| 28 | float yaw90 = glm::radians(rotation.y + 90); |
| 29 | |
| 30 | if (sf::Keyboard::isKeyPressed(Key_Binds::getKey(Key_Binds::Control::Player_Forwards))) |
| 31 | { |
| 32 | change.x -= glm::cos(yaw90) * speed; |
| 33 | change.z -= glm::sin(yaw90) * speed; |
| 34 | } |
| 35 | |
| 36 | if (sf::Keyboard::isKeyPressed(Key_Binds::getKey(Key_Binds::Control::Player_Back))) |
| 37 | { |
| 38 | change.x += glm::cos(yaw90) * speed; |
| 39 | change.z += glm::sin(yaw90) * speed; |
| 40 | } |
| 41 | |
| 42 | if (sf::Keyboard::isKeyPressed(Key_Binds::getKey(Key_Binds::Control::Player_Left))) |
| 43 | { |
| 44 | change.x -= glm::cos(yaw) * speed; |
| 45 | change.z -= glm::sin(yaw) * speed; |
| 46 | } |
| 47 | |
| 48 | if (sf::Keyboard::isKeyPressed(Key_Binds::getKey(Key_Binds::Control::Player_Right))) |
| 49 | { |
| 50 | change.x += glm::cos(yaw) * speed; |
| 51 | change.z += glm::sin(yaw) * speed; |
| 52 | } |
| 53 | |
| 54 | if (sf::Keyboard::isKeyPressed(Key_Binds::getKey(Key_Binds::Control::Player_Up))) |
| 55 | { |
| 56 | if (m_isFlying) |
| 57 | { |
| 58 | change.y += speed; |
| 59 | } |
| 60 | else if (m_isOnGround) |
| 61 | { |
| 62 | change.y += 12; |
| 63 | } |
| 64 | else if (m_isInLiquid) |
| 65 | { |
| 66 | change.y += 0.5; |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | if (sf::Keyboard::isKeyPressed(Key_Binds::getKey(Key_Binds::Control::Player_Down))) |
| 71 | { |
| 72 | change.y -= speed; |
| 73 | } |