From 517c2939d77fcc5242ce047eadd0a07d609fbd00 Mon Sep 17 00:00:00 2001 From: MatusGuy <85036874+MatusGuy@users.noreply.github.com> Date: Thu, 13 Jul 2023 13:22:51 +0100 Subject: [PATCH] Rublight sparkle is played when someone steps on it. (#2534) 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. --- data/images/objects/rublight/rublight.sprite | 44 ++++++++++---------- src/object/rublight.cpp | 12 ++++-- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/data/images/objects/rublight/rublight.sprite b/data/images/objects/rublight/rublight.sprite index f5568b4104f..323f1057f14 100644 --- a/data/images/objects/rublight/rublight.sprite +++ b/data/images/objects/rublight/rublight.sprite @@ -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") + ) +) diff --git a/src/object/rublight.cpp b/src/object/rublight.cpp index 586d7172465..90b134d22c6 100644 --- a/src/object/rublight.cpp +++ b/src/object/rublight.cpp @@ -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 vColor; if (mapping.get("color", vColor)) @@ -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(stored_energy, strength); if (state == STATE_DARK) @@ -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: