Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
clasher113 committed Feb 4, 2025
1 parent 2105d56 commit aeb5312
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/audio/AL/ALAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ void ALSpeaker::play() {
AL_CHECK(alSourcef(
source,
AL_GAIN,
volume * p_channel->getVolume() * get_channel(0)->getVolume()
volume * p_channel->getVolume()
));
AL_CHECK(alSourcePlay(source));
}
Expand Down
7 changes: 5 additions & 2 deletions src/graphics/ui/elements/InputBindBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ InputBindBox::InputBindBox(Binding& binding, glm::vec4 padding)
label(std::make_shared<Label>(L"")) {
add(label);
setScrollable(false);
hoverColor = glm::vec4(0.05f, 0.1f, 0.2f, 0.75f);
}

void InputBindBox::drawBackground(const DrawContext& pctx, const Assets&) {
Expand All @@ -25,8 +26,10 @@ void InputBindBox::drawBackground(const DrawContext& pctx, const Assets&) {
}

void InputBindBox::clicked(GUI*, mousecode button) {
binding.reset(button);
defocus();
if (isFocused()) {
binding.reset(button);
defocus();
}
}

void InputBindBox::keyPressed(keycode key) {
Expand Down
3 changes: 1 addition & 2 deletions src/graphics/ui/elements/InputBindBox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ namespace gui {

class InputBindBox : public Panel {
protected:
glm::vec4 hoverColor {0.05f, 0.1f, 0.2f, 0.75f};
glm::vec4 focusedColor {0.0f, 0.0f, 0.0f, 1.0f};
glm::vec4 focusedColor {0.1f, 0.15f, 0.35f, 0.75f};
std::shared_ptr<Label> label;
Binding& binding;
public:
Expand Down
34 changes: 18 additions & 16 deletions src/logic/PlayerController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,24 @@ glm::vec3 CameraControl::updateCameraShaking(
const float ov = CAM_SHAKE_OFFSET_Y;
const glm::vec3& vel = hitbox.velocity;

interpVel = interpVel * (1.0f - delta * 5) + vel * delta * 0.1f;
if (hitbox.grounded && interpVel.y < 0.0f) {
interpVel.y *= -30.0f;
}
shake = shake * (1.0f - delta * k);
float oh = CAM_SHAKE_OFFSET;
if (hitbox.grounded) {
float f = glm::length(glm::vec2(vel.x, vel.z));
shakeTimer += delta * f * CAM_SHAKE_SPEED;
shake += f * delta * k;
oh *= glm::sqrt(f);
}
if (settings.shaking.get()) {
shake = shake * (1.0f - delta * k);
float oh = CAM_SHAKE_OFFSET;
if (hitbox.grounded) {
float f = glm::length(glm::vec2(vel.x, vel.z));
shakeTimer += delta * f * CAM_SHAKE_SPEED;
shake += f * delta * k;
oh *= glm::sqrt(f);
}

offset += camera->right * glm::sin(shakeTimer) * oh * shake;
offset += camera->up * glm::abs(glm::cos(shakeTimer)) * ov * shake;
offset += camera->right * glm::sin(shakeTimer) * oh * shake;
offset += camera->up * glm::abs(glm::cos(shakeTimer)) * ov * shake;
}
if (settings.inertia.get()) {
interpVel = interpVel * (1.0f - delta * 5) + vel * delta * 0.1f;
if (hitbox.grounded && interpVel.y < 0.0f) {
interpVel.y *= -30.0f;
}
offset -= glm::min(interpVel * 0.05f, 1.0f);
}
return offset;
Expand All @@ -124,7 +126,7 @@ void CameraControl::updateFovEffects(
if (crouch) {
offset += glm::vec3(0.f, CROUCH_SHIFT_Y, 0.f);
zoomValue = CROUCH_ZOOM;
} else if (input.sprint) {
} else if (input.sprint && (input.moveForward || input.moveBack || input.moveLeft || input.moveRight)) {
zoomValue = RUN_ZOOM;
}
if (input.zoom) zoomValue *= C_ZOOM;
Expand Down Expand Up @@ -161,7 +163,7 @@ void CameraControl::update(

if (auto hitbox = player.getHitbox()) {
offset.y += hitbox->halfsize.y * (0.7f / 0.9f);
if (settings.shaking.get() && !input.cheat) {
if (!input.cheat) {
offset += updateCameraShaking(*hitbox, delta);
}
if (settings.fovEffects.get()) {
Expand Down

0 comments on commit aeb5312

Please sign in to comment.