A lantern with black light is turned off.
authorWolfgang Becker <uafr@gmx.de>
Sun, 17 Sep 2006 17:19:16 +0000 (17:19 +0000)
committerWolfgang Becker <uafr@gmx.de>
Sun, 17 Sep 2006 17:19:16 +0000 (17:19 +0000)
SVN-Revision: 4241

data/images/objects/lantern/lantern-off.png [new file with mode: 0644]
data/images/objects/lantern/lantern.sprite
data/images/objects/lantern/lantern.xcf
src/object/lantern.cpp
src/object/lantern.hpp

diff --git a/data/images/objects/lantern/lantern-off.png b/data/images/objects/lantern/lantern-off.png
new file mode 100644 (file)
index 0000000..74f9379
Binary files /dev/null and b/data/images/objects/lantern/lantern-off.png differ
index dc4efd9..ab7513b 100644 (file)
@@ -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")
+      )
 )
index c14aeaa..7a1f03d 100644 (file)
Binary files a/data/images/objects/lantern/lantern.xcf and b/data/images/objects/lantern/lantern.xcf differ
index 41c04f0..7295c61 100644 (file)
@@ -29,12 +29,11 @@ Lantern::Lantern(const lisp::Lisp& reader)
 {
   //get color from lisp
   std::vector<float> 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);
index 13356cd..c5352df 100644 (file)
@@ -36,6 +36,7 @@ public:
 private:
   Color lightcolor;
   Sprite* lightsprite;
+  void updateColor();
 };
 
 #endif