diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2018-02-03 18:42:25 +0100 |
---|---|---|
committer | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2018-02-03 18:42:25 +0100 |
commit | 7492187ad2e16c7398ca4ed812a57045c3d42d68 (patch) | |
tree | 0bfc9a274bf1616b5220b9567ff1c422f4391b12 /src/GameState.cpp | |
parent | Implemented basic digging (diff) | |
download | AltCraft-7492187ad2e16c7398ca4ed812a57045c3d42d68.tar AltCraft-7492187ad2e16c7398ca4ed812a57045c3d42d68.tar.gz AltCraft-7492187ad2e16c7398ca4ed812a57045c3d42d68.tar.bz2 AltCraft-7492187ad2e16c7398ca4ed812a57045c3d42d68.tar.lz AltCraft-7492187ad2e16c7398ca4ed812a57045c3d42d68.tar.xz AltCraft-7492187ad2e16c7398ca4ed812a57045c3d42d68.tar.zst AltCraft-7492187ad2e16c7398ca4ed812a57045c3d42d68.zip |
Diffstat (limited to '')
-rw-r--r-- | src/GameState.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/GameState.cpp b/src/GameState.cpp index 20926e0..650cd6f 100644 --- a/src/GameState.cpp +++ b/src/GameState.cpp @@ -27,7 +27,16 @@ void GameState::Update(float deltaTime) { PUSH_EVENT("SendPacket",packet); } - selectedBlock = Vector(Vector(player->pos.x,player->pos.y,player->pos.z) - Vector(-1,0,0)); + + double playerYaw = Entity::DecodeYaw(player->yaw); + double playerPitch = Entity::DecodePitch(player->pitch); + + glm::vec3 direction; + direction.x = cos(glm::radians(playerYaw)) * cos(glm::radians(playerPitch)); + direction.y = sin(glm::radians(playerPitch)); + direction.z = sin(glm::radians(playerYaw)) * cos(glm::radians(playerPitch)); + + selectedBlock = world.Raycast(player->pos + player->EyeOffset, direction, distanceToSelectedBlock); } } @@ -404,7 +413,7 @@ void GameState::HandleMovement(GameState::Direction direction, float deltaTime) const double playerSpeed = 43; float velocity = playerSpeed * deltaTime; - + double playerYaw = Entity::DecodeYaw(player->yaw); double playerPitch = Entity::DecodePitch(player->pitch); |