diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2018-08-08 21:39:14 +0200 |
---|---|---|
committer | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2018-08-08 21:39:14 +0200 |
commit | 32d836cb88db783c807c228fa2932ddecc1a8d07 (patch) | |
tree | 0fa82f23c098b2caf2c7996affb0068d499ee4fa /src/GameState.cpp | |
parent | Disabled collisions for double plants and flowers (diff) | |
download | AltCraft-32d836cb88db783c807c228fa2932ddecc1a8d07.tar AltCraft-32d836cb88db783c807c228fa2932ddecc1a8d07.tar.gz AltCraft-32d836cb88db783c807c228fa2932ddecc1a8d07.tar.bz2 AltCraft-32d836cb88db783c807c228fa2932ddecc1a8d07.tar.lz AltCraft-32d836cb88db783c807c228fa2932ddecc1a8d07.tar.xz AltCraft-32d836cb88db783c807c228fa2932ddecc1a8d07.tar.zst AltCraft-32d836cb88db783c807c228fa2932ddecc1a8d07.zip |
Diffstat (limited to '')
-rw-r--r-- | src/GameState.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/GameState.cpp b/src/GameState.cpp index 6c2ad42..c42092a 100644 --- a/src/GameState.cpp +++ b/src/GameState.cpp @@ -484,7 +484,7 @@ void GameState::HandleMovement(GameState::Direction direction, float deltaTime) glm::vec3 front, right, worldUp, up; worldUp = glm::vec3(0.0f, 1.0f, 0.0f); front.x = cos(glm::radians(playerYaw)) * cos(glm::radians(playerPitch)); - front.y = 0; + front.y = player->isFlying ? sin(glm::radians(playerPitch)): 0; front.z = sin(glm::radians(playerYaw)) * cos(glm::radians(playerPitch)); front = glm::normalize(front); right = glm::normalize(glm::cross(front, worldUp)); @@ -513,10 +513,13 @@ void GameState::HandleMovement(GameState::Direction direction, float deltaTime) } case JUMP: - if (player->onGround) { + if (player->onGround && !player->isFlying) { vel.y += 10; player->onGround = false; - } + } else + if (player->isFlying) { + vel += up * velocity; + } break; } player->vel = VectorF(vel.x, vel.y, vel.z); |