Skip to content

Commit

Permalink
Increase movement speed when control is held
Browse files Browse the repository at this point in the history
  • Loading branch information
stuarthayhurst committed Feb 2, 2024
1 parent d8816da commit 4811265
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ void focalToggleCallback(std::vector<int>, int, void*) {
!ammonite::settings::graphics::post::getFocalDepthEnabled());
}

void sprintToggleCallback(std::vector<int>, int action, void*) {
float movementSpeed = 0.0f;
if (action == GLFW_REPEAT) {
return;
}

movementSpeed = ammonite::settings::controls::getMovementSpeed();
movementSpeed *= (action == GLFW_PRESS) ? 2.0f : (1.0f / 2.0f);
ammonite::settings::controls::setMovementSpeed(movementSpeed);
}

void cameraCycleCallback(std::vector<int>, int, void* userPtr) {
CameraData* cameraData = (CameraData*)userPtr;
cameraData->cameraIndex = (cameraData->cameraIndex + 1) % cameraData->cameraIds.size();
Expand Down Expand Up @@ -251,6 +262,8 @@ int main(int argc, char* argv[]) {
fullscreenToggleCallback, nullptr));
keybindIds.push_back(ammonite::input::registerToggleKeybind(
GLFW_KEY_Z, focalToggleCallback, nullptr));
keybindIds.push_back(ammonite::input::registerKeybind(
GLFW_KEY_LEFT_CONTROL, sprintToggleCallback, nullptr));
keybindIds.push_back(ammonite::input::registerToggleKeybind(
GLFW_KEY_B, cameraCycleCallback, &cameraData));

Expand Down

0 comments on commit 4811265

Please sign in to comment.