From: LMH Date: Tue, 9 Apr 2013 07:10:03 +0000 (-1000) Subject: Added glow and ice vulnerability to flame X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=3e1eec1572f3c06cb73682e9dee8061da16aa476;p=supertux.git Added glow and ice vulnerability to flame --- diff --git a/data/images/creatures/flame/flame-fade-0.png b/data/images/creatures/flame/flame-fade-0.png new file mode 100644 index 000000000..55be7eb8d 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 index 000000000..23ab72a60 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 index 000000000..75aba36c9 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 index 000000000..2fa787b8e Binary files /dev/null and b/data/images/creatures/flame/flame-fade-3.png differ diff --git a/data/images/creatures/flame/flame.sprite b/data/images/creatures/flame/flame.sprite index 81a447a44..3bf4e35e4 100644 --- a/data/images/creatures/flame/flame.sprite +++ b/data/images/creatures/flame/flame.sprite @@ -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")) diff --git a/src/badguy/flame.cpp b/src/badguy/flame.cpp index 5387b74ba..28cea989f 100644 --- a/src/badguy/flame.cpp +++ b/src/badguy/flame.cpp @@ -19,7 +19,12 @@ #include #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 */ diff --git a/src/badguy/flame.hpp b/src/badguy/flame.hpp index bc04b7e9c..4e5abd032 100644 --- a/src/badguy/flame.hpp +++ b/src/badguy/flame.hpp @@ -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 sound_source; };