Skip to content

Commit

Permalink
fix: issue with truncation of victory message opacity
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahkittyy committed Oct 23, 2022
1 parent f2acd13 commit caa2335
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .tasks
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[generate]

command=cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1 ..
command=cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=1 ..
cwd=build

[build]
Expand Down
12 changes: 6 additions & 6 deletions game/world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,9 @@ void world::update(sf::Time dt) {

if (won()) {
sf::Color opacity = m_space_to_retry.getColor();
int alpha = opacity.a;
alpha += 255.f * dt.asSeconds();
alpha = std::min(255, alpha);
opacity.a = alpha;
m_victory_alpha += 255.f * dt.asSeconds();
m_victory_alpha = std::min(255.f, m_victory_alpha);
opacity.a = m_victory_alpha;
m_space_to_retry.setColor(opacity);
m_game_clear.setColor(opacity);
if (m_just_jumped()) {
Expand Down Expand Up @@ -699,8 +698,9 @@ void world::draw(sf::RenderTarget& t, sf::RenderStates s) const {

void world::m_player_win() {
if (m_touched_goal) return;
m_touched_goal = true;
m_dashing = false;
m_touched_goal = true;
m_victory_alpha = 0;
m_dashing = false;
m_space_to_retry.setColor(sf::Color(255, 255, 255, 0));
m_game_clear.setColor(sf::Color(255, 255, 255, 0));
m_r.play_sound("victory");
Expand Down
1 change: 1 addition & 0 deletions game/world.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class world : public sf::Drawable, public sf::Transformable {
// messages shown on victory
sf::Sprite m_game_clear;
sf::Sprite m_space_to_retry;
float m_victory_alpha;

// PLAYER DATA //

Expand Down

0 comments on commit caa2335

Please sign in to comment.