From: Wolfgang Becker Date: Sun, 17 Sep 2006 17:19:16 +0000 (+0000) Subject: A lantern with black light is turned off. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=69be5aee32ec5b3eb1c65f4569f92746cc8d294c;p=supertux.git A lantern with black light is turned off. SVN-Revision: 4241 --- diff --git a/data/images/objects/lantern/lantern-off.png b/data/images/objects/lantern/lantern-off.png new file mode 100644 index 000000000..74f937991 Binary files /dev/null and b/data/images/objects/lantern/lantern-off.png differ diff --git a/data/images/objects/lantern/lantern.sprite b/data/images/objects/lantern/lantern.sprite index dc4efd97d..ab7513bb5 100644 --- a/data/images/objects/lantern/lantern.sprite +++ b/data/images/objects/lantern/lantern.sprite @@ -1,7 +1,7 @@ (supertux-sprite (action - (hitbox 16 8 34 40) (name "normal") + (hitbox 16 8 34 41) (images "lantern-1.png" "lantern-2.png" @@ -9,4 +9,9 @@ "lantern-4.png" ) ) + (action + (name "off") + (hitbox 16 8 34 41) + (images "lantern-off.png") + ) ) diff --git a/data/images/objects/lantern/lantern.xcf b/data/images/objects/lantern/lantern.xcf index c14aeaae7..7a1f03dcd 100644 Binary files a/data/images/objects/lantern/lantern.xcf and b/data/images/objects/lantern/lantern.xcf differ diff --git a/src/object/lantern.cpp b/src/object/lantern.cpp index 41c04f0a8..7295c610f 100644 --- a/src/object/lantern.cpp +++ b/src/object/lantern.cpp @@ -29,12 +29,11 @@ Lantern::Lantern(const lisp::Lisp& reader) { //get color from lisp std::vector vColor; - reader.get_vector("color", vColor ); - lightcolor = Color( vColor ); - + reader.get_vector("color", vColor); + lightcolor = Color(vColor); lightsprite = sprite_manager->create("images/objects/lightmap_light/lightmap_light.sprite"); - lightsprite->set_color(lightcolor); lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE)); + updateColor(); } Lantern::~Lantern() @@ -43,6 +42,17 @@ Lantern::~Lantern() } void +Lantern::updateColor(){ + lightsprite->set_color(lightcolor); + //Turn lantern off if light is black + if(lightcolor.red == 0 && lightcolor.green == 0 && lightcolor.blue == 0){ + sprite->set_action("off"); + } else { + sprite->set_action("normal"); + } +} + +void Lantern::draw(DrawingContext& context){ //Draw the Sprite. MovingSprite::draw(context); diff --git a/src/object/lantern.hpp b/src/object/lantern.hpp index 13356cd85..c5352dfc5 100644 --- a/src/object/lantern.hpp +++ b/src/object/lantern.hpp @@ -36,6 +36,7 @@ public: private: Color lightcolor; Sprite* lightsprite; + void updateColor(); }; #endif