Skip to content

Commit

Permalink
Brighten sector on lightning hit
Browse files Browse the repository at this point in the history
  • Loading branch information
tobbi committed Sep 6, 2023
1 parent 637dcd4 commit dbed397
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/object/thunderstorm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "audio/sound_manager.hpp"
#include "editor/editor.hpp"
#include "object/ambient_light.hpp"
#include "object/background.hpp"
#include "object/electrifier.hpp"
#include "supertux/level.hpp"
Expand Down Expand Up @@ -95,6 +96,10 @@ Thunderstorm::update(float )
lightning();
time_to_thunder.start(interval);
}
if(flash_display_timer.check()) {
Sector::current()->get_singleton_by_type<AmbientLight>()
.set_ambient_light(last_ambient_color);
}
}

void
Expand Down Expand Up @@ -136,6 +141,7 @@ Thunderstorm::thunder()
{
SoundManager::current()->play("sounds/thunder.wav");
set_background_color(Color(0.4f, 0.4f, 0.4f));
last_ambient_color = Sector::current()->get_singleton_by_type<AmbientLight>().get_ambient_light();
}

void
Expand All @@ -148,6 +154,7 @@ Thunderstorm::lightning()
}

set_background_color(Color::WHITE);
Sector::current()->get_singleton_by_type<AmbientLight>().set_ambient_light(Color::LIGHTNING_HIT_COLOR);
}

void
Expand Down
1 change: 1 addition & 0 deletions src/object/thunderstorm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class Thunderstorm final : public GameObject,
Timer flash_display_timer; /**< counts down while flash is displayed */

std::map<uint32_t, uint32_t> changing_tiles; /**< preserves the tiles which an electrocution should change */
Color last_ambient_color;

private:
Thunderstorm(const Thunderstorm&) = delete;
Expand Down
1 change: 1 addition & 0 deletions src/video/color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const Color Color::CYAN(0.0, 1.0, 1.0);
const Color Color::MAGENTA(1.0, 0.0, 1.0);
const Color Color::YELLOW(1.0, 1.0, 0.0);
const Color Color::WHITE(1.0, 1.0, 1.0);
const Color Color::LIGHTNING_HIT_COLOR(0.6, 0.6, 0.6, 0.5);

Color::Color() :
red(0),
Expand Down
1 change: 1 addition & 0 deletions src/video/color.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class Color final
static const Color MAGENTA;
static const Color YELLOW;
static const Color WHITE;
static const Color LIGHTNING_HIT_COLOR;

public:
static Color from_rgb888(uint8_t r, uint8_t g, uint8_t b)
Expand Down

0 comments on commit dbed397

Please sign in to comment.