X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fbadguy%2Fflame.cpp;h=a06039f2d9acb4ecb3271bef396f918ebb7665c1;hb=e6ff6a3532bc3836ddebe2d539d41688d01c41a3;hp=0de567db2ab98a986501963ac543e5d763dfac71;hpb=65a0b6f7ec1123cff959e13e1a4919dc70fe4e85;p=supertux.git diff --git a/src/badguy/flame.cpp b/src/badguy/flame.cpp index 0de567db2..a06039f2d 100644 --- a/src/badguy/flame.cpp +++ b/src/badguy/flame.cpp @@ -1,12 +1,10 @@ -// $Id$ -// // SuperTux // Copyright (C) 2006 Matthias Braun // -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,40 +12,43 @@ // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// along with this program. If not, see . + +#include "badguy/flame.hpp" -#include +#include -#include "flame.hpp" -#include "log.hpp" +#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 SOUNDFILE = "sounds/flame.wav"; +static const std::string FLAME_SOUND = "sounds/flame.wav"; -Flame::Flame(const lisp::Lisp& reader) - : BadGuy(reader, "images/creatures/flame/flame.sprite", LAYER_FLOATINGOBJECTS), angle(0), radius(100), speed(2) +Flame::Flame(const Reader& reader) : + BadGuy(reader, "images/creatures/flame/flame.sprite", LAYER_FLOATINGOBJECTS), + angle(0), + radius(100), + speed(2), + light(0.0f,0.0f,0.0f), + lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-small.sprite")), + sound_source() { reader.get("radius", radius); reader.get("speed", speed); bbox.set_pos(Vector(start_position.x + cos(angle) * radius, start_position.y + sin(angle) * radius)); countMe = false; - sound_manager->preload(SOUNDFILE); + sound_manager->preload(FLAME_SOUND); set_colgroup_active(COLGROUP_TOUCHABLE); -} - -void -Flame::write(lisp::Writer& writer) -{ - writer.start_list("flame"); - - writer.write("x", start_position.x); - writer.write("y", start_position.y); - writer.write("radius", radius); - writer.write("speed", speed); - - writer.end_list("flame"); + + lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE)); + lightsprite->set_color(Color(0.21f, 0.13f, 0.08f)); } void @@ -59,12 +60,32 @@ Flame::active_update(float elapsed_time) movement = newpos - get_pos(); sound_source->set_position(get_pos()); + + if (sprite->get_action() == "fade" && 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); + sprite->draw(context, get_pos(), layer); + lightsprite->draw(context, get_bbox().get_middle(), 0); + context.pop_target(); + } + } } void Flame::activate() { - sound_source.reset(sound_manager->create_sound_source(SOUNDFILE)); + sound_source.reset(sound_manager->create_sound_source(FLAME_SOUND)); sound_source->set_position(get_pos()); sound_source->set_looping(true); sound_source->set_gain(2.0); @@ -78,9 +99,28 @@ Flame::deactivate() sound_source.reset(); } + void Flame::kill_fall() { } -IMPLEMENT_FACTORY(Flame, "flame") +void +Flame::freeze() +{ + sound_manager->play("sounds/sizzle.ogg", get_pos()); + sprite->set_action("fade", 1); + Sector::current()->add_object(new SpriteParticle("images/objects/particles/smoke.sprite", "default", bbox.get_middle(), ANCHOR_MIDDLE, Vector(0, -150), Vector(0,0), LAYER_BACKGROUNDTILES+2)); + set_group(COLGROUP_DISABLED); + + // start dead-script + run_dead_script(); +} + +bool +Flame::is_freezable() const +{ + return true; +} + +/* EOF */