Skip to content

Commit 08d3bc9

Browse files
author
JekiTheMonkey
committed
Fixed a bug with starting rectangle size in key press visualizer
1 parent 1743d83 commit 08d3bc9

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

Source/GfxButton.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,11 @@ GfxButton::GfxButton(const unsigned idx, const TextureHolder& textureHolder, con
4444
void GfxButton::update(bool buttonPressed)
4545
{
4646
if (Settings::LightAnimation)
47-
{
4847
buttonPressed ? lightKey() : fadeKey();
49-
}
50-
5148
if (Settings::PressAnimation)
52-
{
5349
buttonPressed ? lowerKey() : raiseKey();
54-
}
5550

51+
float speed = -Settings::KeyPressVisSpeed / 10.f;
5652
if (Settings::KeyPressVisToggle)
5753
{
5854
// Create a new rectangle on button press if last frame the button was not pressed
@@ -61,7 +57,7 @@ void GfxButton::update(bool buttonPressed)
6157
const auto &buttonSprite = *mSprites[ButtonSprite];
6258
float width = buttonSprite.getGlobalBounds().width;
6359
float height = buttonSprite.getGlobalBounds().height;
64-
sf::RectangleShape rect(sf::Vector2f(width, 0.1f));
60+
sf::RectangleShape rect(sf::Vector2f(width, speed));
6561
rect.setFillColor(Settings::KeyPressVisColor);
6662
rect.setOrigin(width / 2.f, height / 2.f);
6763
mPressRects.push_back(std::move(rect));
@@ -73,11 +69,11 @@ void GfxButton::update(bool buttonPressed)
7369
{
7470
auto &rect = mPressRects.back();
7571
auto oldSize = rect.getSize();
76-
rect.setSize(sf::Vector2f(oldSize.x, oldSize.y - Settings::KeyPressVisSpeed / 10.f));
72+
rect.setSize(sf::Vector2f(oldSize.x, oldSize.y + speed));
7773
}
7874
}
7975

80-
sf::Vector2f movement(0.f, -Settings::KeyPressVisSpeed / 10.f);
76+
sf::Vector2f movement(0.f, speed);
8177

8278
// Move each rectangle by speed
8379
for (auto &rect : mPressRects)
@@ -94,8 +90,8 @@ void GfxButton::draw(sf::RenderTarget &target, sf::RenderStates states) const
9490
{
9591
states.transform *= getTransform();
9692
auto pressRectTransf = states;
97-
pressRectTransf.transform.rotate(-Settings::KeyPressVisRotation);
98-
pressRectTransf.transform = pressRectTransf.transform.translate(Settings::KeyPressVisOrig.x, -Settings::KeyPressVisOrig.y);
93+
// pressRectTransf.transform.rotate(-Settings::KeyPressVisRotation);
94+
// pressRectTransf.transform = pressRectTransf.transform.translate(Settings::KeyPressVisOrig.x, -Settings::KeyPressVisOrig.y);
9995

10096
for (const auto &rect : mPressRects)
10197
target.draw(rect, pressRectTransf);

0 commit comments

Comments
 (0)