From 32d836cb88db783c807c228fa2932ddecc1a8d07 Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Thu, 9 Aug 2018 00:39:14 +0500 Subject: Implemented Creative Flight --- src/GameState.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/GameState.cpp') 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); -- cgit v1.2.3