Skip to content

Commit

Permalink
Rublight sparkle is played when someone steps on it. (#2534)
Browse files Browse the repository at this point in the history
In this case, "someone" means the player, a walking badguy, or an explosion. More of a feature than a fix. Also changed light colour to white to match current sprite.
  • Loading branch information
MatusGuy authored Jul 13, 2023
1 parent 3234bac commit 517c293
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 25 deletions.
44 changes: 22 additions & 22 deletions data/images/objects/rublight/rublight.sprite
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
(supertux-sprite
(action
(name "default")
(fps 8)
(images "rublight-0.png"
"rublight-1.png"
"rublight-2.png"
"rublight-3.png"
"rublight-4.png"
"rublight-5.png"
"rublight-6.png"
"rublight-7.png"
"rublight-8.png"
"rublight-9.png"
"rublight-10.png"
"rublight-0.png"
"rublight-0.png"
"rublight-0.png"
"rublight-0.png"
"rublight-0.png")
)
)
(supertux-sprite
(action
(name "active")
(fps 8)
(loops 1)
(images "rublight-0.png"
"rublight-1.png"
"rublight-2.png"
"rublight-3.png"
"rublight-4.png"
"rublight-5.png"
"rublight-6.png"
"rublight-7.png"
"rublight-8.png"
"rublight-9.png"
"rublight-10.png")
)
(action
(name "inactive")
(images "rublight-0.png")
)
)
12 changes: 9 additions & 3 deletions src/object/rublight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ RubLight::RubLight(const ReaderMapping& mapping) :
stored_energy(0),
light(SpriteManager::current()->create(
"images/objects/lightmap_light/lightmap_light.sprite")),
color(1.0f, 0.5f, 0.3f),
color(1.f, 1.f, 1.f),
fading_speed(5.0f),
strength_multiplier(1.0f)
{
m_sprite->set_action("normal");
m_sprite->set_action("inactive");

std::vector<float> vColor;
if (mapping.get("color", vColor))
Expand Down Expand Up @@ -95,6 +95,7 @@ void RubLight::rub(float strength)
{
if (strength <= 0)
return;
m_sprite->set_action("active");
strength *= strength_multiplier;
stored_energy = std::max<float>(stored_energy, strength);
if (state == STATE_DARK)
Expand All @@ -104,9 +105,14 @@ void RubLight::rub(float strength)
void
RubLight::update(float dt_sec)
{
if (m_sprite->get_action() == "active" && m_sprite->animation_done())
{
m_sprite->set_action("inactive");
}

switch (state) {
case STATE_DARK:
// Nothing to do
m_sprite->set_action("inactive");
break;

case STATE_FADING:
Expand Down

0 comments on commit 517c293

Please sign in to comment.