Added glow and ice vulnerability to flame
authorLMH <lmh.0013@gmail.com>
Tue, 9 Apr 2013 07:10:03 +0000 (21:10 -1000)
committerLMH <lmh.0013@gmail.com>
Tue, 9 Apr 2013 07:10:03 +0000 (21:10 -1000)
data/images/creatures/flame/flame-fade-0.png [new file with mode: 0644]
data/images/creatures/flame/flame-fade-1.png [new file with mode: 0644]
data/images/creatures/flame/flame-fade-2.png [new file with mode: 0644]
data/images/creatures/flame/flame-fade-3.png [new file with mode: 0644]
data/images/creatures/flame/flame.sprite
src/badguy/flame.cpp
src/badguy/flame.hpp

diff --git a/data/images/creatures/flame/flame-fade-0.png b/data/images/creatures/flame/flame-fade-0.png
new file mode 100644 (file)
index 0000000..55be7eb
Binary files /dev/null and b/data/images/creatures/flame/flame-fade-0.png differ
diff --git a/data/images/creatures/flame/flame-fade-1.png b/data/images/creatures/flame/flame-fade-1.png
new file mode 100644 (file)
index 0000000..23ab72a
Binary files /dev/null and b/data/images/creatures/flame/flame-fade-1.png differ
diff --git a/data/images/creatures/flame/flame-fade-2.png b/data/images/creatures/flame/flame-fade-2.png
new file mode 100644 (file)
index 0000000..75aba36
Binary files /dev/null and b/data/images/creatures/flame/flame-fade-2.png differ
diff --git a/data/images/creatures/flame/flame-fade-3.png b/data/images/creatures/flame/flame-fade-3.png
new file mode 100644 (file)
index 0000000..2fa787b
Binary files /dev/null and b/data/images/creatures/flame/flame-fade-3.png differ
index 81a447a..3bf4e35 100644 (file)
@@ -5,6 +5,15 @@
   (images "flame-0.png"
           "flame-1.png"))
  (action
+  (hitbox 0 0 31.8 31.8)
+  (name "fade")
+  (fps 5)
+  (images "flame-1.png"
+          "flame-fade-0.png"
+          "flame-fade-1.png"
+          "flame-fade-2.png"
+          "flame-fade-3.png"))
+ (action
   (hitbox 96 96 127.8 31.8)
   (name "editor")
   (images "flame-editor.png"))
index 5387b74..28cea98 100644 (file)
 #include <math.h>
 
 #include "audio/sound_manager.hpp"
+#include "math/random_generator.hpp"
+#include "sprite/sprite.hpp"
+#include "sprite/sprite_manager.hpp"
+#include "object/sprite_particle.hpp"
 #include "supertux/object_factory.hpp"
+#include "supertux/sector.hpp"
 #include "util/reader.hpp"
 
 static const std::string FLAME_SOUND = "sounds/flame.wav";
@@ -29,6 +34,9 @@ Flame::Flame(const Reader& reader) :
   angle(0), 
   radius(100), 
   speed(2),
+  fading(true),
+  light(0.0f,0.0f,0.0f),
+  lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-tiny.sprite")),
   sound_source()
 {
   reader.get("radius", radius);
@@ -39,6 +47,9 @@ Flame::Flame(const Reader& reader) :
   sound_manager->preload(FLAME_SOUND);
 
   set_colgroup_active(COLGROUP_TOUCHABLE);
+  
+  lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
+  lightsprite->set_color(Color(0.21f, 0.13f, 0.08f));
 }
 
 void
@@ -50,6 +61,26 @@ Flame::active_update(float elapsed_time)
   movement = newpos - get_pos();
 
   sound_source->set_position(get_pos());
+  
+  if(fading)
+    if (sprite->animation_done()) remove_me();
+}
+
+void
+Flame::draw(DrawingContext& context)
+{
+  //Draw the Sprite.
+  sprite->draw(context, get_pos(), LAYER_OBJECTS);
+  //Draw the light if dark
+  if(true){
+    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
@@ -69,9 +100,31 @@ Flame::deactivate()
   sound_source.reset();
 }
 
+
 void
 Flame::kill_fall()
 {
 }
 
+void
+Flame::freeze()
+{
+  sound_manager->play("sounds/fizz.wav", get_pos());
+  sprite->set_action("fade", 1);
+  Vector ppos = bbox.get_middle();
+  Vector pspeed = Vector(0, -150);
+  Vector paccel = Vector(0,0);
+  Sector::current()->add_object(new SpriteParticle("images/objects/particles/smoke.sprite", "default", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_BACKGROUNDTILES+2));
+  fading = true;
+  
+  // start dead-script
+  run_dead_script();
+}
+
+bool
+Flame::is_freezable() const
+{
+  return true;
+}
+
 /* EOF */
index bc04b7e..4e5abd0 100644 (file)
@@ -31,12 +31,19 @@ public:
   void deactivate();
 
   void active_update(float elapsed_time);
+  void draw(DrawingContext& context);
   void kill_fall();
 
+  void freeze();
+  bool is_freezable() const;
+
 private:
   float angle;
   float radius;
   float speed;
+  bool fading;
+  Color light;
+  SpritePtr lightsprite;
 
   std::auto_ptr<SoundSource> sound_source;
 };