Skip to content

Commit

Permalink
Rotation interia
Browse files Browse the repository at this point in the history
  • Loading branch information
Null committed Feb 19, 2018
1 parent 87989f9 commit 1b5a210
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/client/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,16 @@ void Player::move(const World& world) {
}

void Player::rotationMove() {
static bool rotationInteria = getJsonValue<bool>(getSettings()["gui"]["rotation_interia"], false);

if (mRotation.x + mRotationSpeed.x > 90.0)
mRotationSpeed.x = 90.0 - mRotation.x;
if (mRotation.x + mRotationSpeed.x < -90.0)
mRotationSpeed.x = -90.0 - mRotation.x;
mRotation += mRotationSpeed;
mRotationDelta = mRotationSpeed;
mRotationSpeed *= 0.6;
if(rotationInteria) mRotationSpeed *= 0.6;
else mRotationSpeed = 0;
}

Player::Player(size_t worldID) : PlayerObject(worldID) {
Expand Down
11 changes: 5 additions & 6 deletions src/gui/gamescene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
#include "renderer/blockrenderer.h"
#include <GL/glew.h>

class PlayerControllerTask : public ReadOnlyTask {
class PlayerUpdateTask : public ReadOnlyTask {
public:
PlayerControllerTask(Player& player) : mPlayer(player) {}
PlayerUpdateTask(Player& player) : mPlayer(player) {}

void task(const ChunkService& cs) override {

Expand Down Expand Up @@ -62,11 +62,10 @@ class PlayerControllerTask : public ReadOnlyTask {
#endif
mPlayer.accelerate(Vec3d(0.0, -2 * speed, 0.0));


// mGUIWidgets.update();
}

std::unique_ptr<ReadOnlyTask> clone() override { return std::make_unique<PlayerControllerTask>(*this); }
std::unique_ptr<ReadOnlyTask> clone() override { return std::make_unique<PlayerUpdateTask>(*this); }

private:
Player& mPlayer;
Expand Down Expand Up @@ -114,7 +113,7 @@ GameScene::GameScene(const std::string& name, const Window& window):
mCurrentWorld->registerChunkTasks(chunkService, mPlayer);
mWorldRenderer.registerTask(chunkService, mPlayer);
chunkService.getTaskDispatcher().addRegularReadOnlyTask(
std::make_unique<PlayerControllerTask>(mPlayer));
std::make_unique<PlayerUpdateTask>(mPlayer));
chunkService.getTaskDispatcher().addRegularReadOnlyTask(
std::make_unique<UpsCounter>(mUpsCounter));

Expand Down Expand Up @@ -178,7 +177,7 @@ void GameScene::render() {

// Camera control by mouse
static const double mouseSensitivity =
getJsonValue<double>(getSettings()["gui"]["mouse_sensitivity"], 0.2);
getJsonValue<double>(getSettings()["gui"]["mouse_sensitivity"], 0.3);
MouseState mouse = Window::getInstance().getMouseMotion();
mPlayer.accelerateRotation(Vec3d(-mouse.y * mouseSensitivity, -mouse.x * mouseSensitivity, 0.0));

Expand Down

0 comments on commit 1b5a210

Please sign in to comment.