Fireballs glow in the dark, and added basic torch sprite of bug 883
authorLMH <lmh.0013@gmail.com>
Thu, 1 Mar 2012 07:26:53 +0000 (21:26 -1000)
committerLMH <lmh.0013@gmail.com>
Tue, 9 Apr 2013 04:44:15 +0000 (18:44 -1000)
data/images/objects/candle/candle-light.xcf [new file with mode: 0644]
data/images/objects/candle/torch/torch-off.png [new file with mode: 0644]
data/images/objects/candle/torch/torch.sprite [new file with mode: 0644]
data/images/objects/candle/torch/torch1.png [new file with mode: 0755]
data/images/objects/candle/torch/torch2.png [new file with mode: 0755]
data/images/objects/candle/torch/torch3.png [new file with mode: 0755]
data/images/objects/candle/torch/torch4.png [new file with mode: 0755]
data/images/objects/lightmap_light/lightmap_light-small.png [new file with mode: 0644]
data/images/objects/lightmap_light/lightmap_light-small.sprite [new file with mode: 0644]
src/object/bullet.cpp
src/object/bullet.hpp

diff --git a/data/images/objects/candle/candle-light.xcf b/data/images/objects/candle/candle-light.xcf
new file mode 100644 (file)
index 0000000..1ab8fb5
Binary files /dev/null and b/data/images/objects/candle/candle-light.xcf differ
diff --git a/data/images/objects/candle/torch/torch-off.png b/data/images/objects/candle/torch/torch-off.png
new file mode 100644 (file)
index 0000000..b83dc51
Binary files /dev/null and b/data/images/objects/candle/torch/torch-off.png differ
diff --git a/data/images/objects/candle/torch/torch.sprite b/data/images/objects/candle/torch/torch.sprite
new file mode 100644 (file)
index 0000000..d86176f
--- /dev/null
@@ -0,0 +1,18 @@
+(supertux-sprite
+  (action
+    (name "on")
+    (images 
+      "torch1.png"
+      "torch2.png"
+      "torch3.png"
+      )
+    )
+  (action
+    (name "off")
+    (hitbox 0 -32 32 32)
+    (images 
+      "torch-off.png"
+      )
+    )
+  )
+
diff --git a/data/images/objects/candle/torch/torch1.png b/data/images/objects/candle/torch/torch1.png
new file mode 100755 (executable)
index 0000000..475bbdb
Binary files /dev/null and b/data/images/objects/candle/torch/torch1.png differ
diff --git a/data/images/objects/candle/torch/torch2.png b/data/images/objects/candle/torch/torch2.png
new file mode 100755 (executable)
index 0000000..340a406
Binary files /dev/null and b/data/images/objects/candle/torch/torch2.png differ
diff --git a/data/images/objects/candle/torch/torch3.png b/data/images/objects/candle/torch/torch3.png
new file mode 100755 (executable)
index 0000000..60757fb
Binary files /dev/null and b/data/images/objects/candle/torch/torch3.png differ
diff --git a/data/images/objects/candle/torch/torch4.png b/data/images/objects/candle/torch/torch4.png
new file mode 100755 (executable)
index 0000000..897245a
Binary files /dev/null and b/data/images/objects/candle/torch/torch4.png differ
diff --git a/data/images/objects/lightmap_light/lightmap_light-small.png b/data/images/objects/lightmap_light/lightmap_light-small.png
new file mode 100644 (file)
index 0000000..f4239c3
Binary files /dev/null and b/data/images/objects/lightmap_light/lightmap_light-small.png differ
diff --git a/data/images/objects/lightmap_light/lightmap_light-small.sprite b/data/images/objects/lightmap_light/lightmap_light-small.sprite
new file mode 100644 (file)
index 0000000..350efca
--- /dev/null
@@ -0,0 +1,7 @@
+(supertux-sprite
+    (action
+      (name "default")
+      (images "lightmap_light-small.png")
+      (hitbox 64 64 0 0)
+    )
+)
index a4da53a..a2e76e8 100644 (file)
 //  You should have received a copy of the GNU General Public License
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+#include "math/random_generator.hpp"
 #include "object/bullet.hpp"
 #include "object/camera.hpp"
+#include "sprite/sprite.hpp"
 #include "sprite/sprite_manager.hpp"
 #include "supertux/globals.hpp"
 #include "supertux/sector.hpp"
@@ -29,6 +31,8 @@ Bullet::Bullet(const Vector& pos, float xm, int dir, BonusType type) :
   physic(),
   life_count(3), 
   sprite(),
+  light(0.0f,0.0f,0.0f),
+  lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-small.sprite")),
   type(type)
 {
   float speed = dir == RIGHT ? BULLET_XM : -BULLET_XM;
@@ -36,7 +40,9 @@ Bullet::Bullet(const Vector& pos, float xm, int dir, BonusType type) :
 
   if(type == FIRE_BONUS) {
     sprite = sprite_manager->create("images/objects/bullets/firebullet.sprite");
-  } else if(type == ICE_BONUS) {
+    lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
+    lightsprite->set_color(Color(0.3f, 0.1f, 0.0f));
+ } else if(type == ICE_BONUS) {
     life_count = 10;
     sprite = sprite_manager->create("images/objects/bullets/icebullet.sprite");
   } else {
@@ -56,6 +62,11 @@ Bullet::~Bullet()
 void
 Bullet::update(float elapsed_time)
 {
+  // cause fireball color to flicker randomly
+  if (gameRandom.rand(5) != 0) {
+    lightsprite->set_color(Color(0.3f + gameRandom.rand(10)/100.0f, 0.1f + gameRandom.rand(20)/100.0f, gameRandom.rand(10)/100.0f));
+  } else
+    lightsprite->set_color(Color(0.3f, 0.1f, 0.0f));
   // remove bullet when it's offscreen
   float scroll_x =
     Sector::current()->camera->get_translation().x;
@@ -76,7 +87,18 @@ Bullet::update(float elapsed_time)
 void
 Bullet::draw(DrawingContext& context)
 {
+  //Draw the Sprite.
   sprite->draw(context, get_pos(), LAYER_OBJECTS);
+  //Draw the light if fire and dark
+  if(type == FIRE_BONUS){
+    context.get_light( get_bbox().get_middle(), &light );
+    if (light.red + light.green < 2.0){
+      context.push_target();
+      context.set_target(DrawingContext::LIGHTMAP);
+      lightsprite->draw(context, get_bbox().get_middle(), 0);
+      context.pop_target();
+    }
+  }
 }
 
 void
index 90977ea..82ea841 100644 (file)
@@ -49,6 +49,8 @@ private:
   Physic physic;
   int life_count;
   SpritePtr sprite;
+  Color light;
+  SpritePtr lightsprite;
   BonusType type;
 };