X-Git-Url: https://git.octo.it/?a=blobdiff_plain;ds=sidebyside;f=src%2Fbadguy%2Flivefire.cpp;h=55c91ad6e18db1a8ea6f3478031363285381232a;hb=575ee7830c331b48172dccacc7a96188f8d6695b;hp=955fad06b423faa918c70cae029dcaa48a24d0a5;hpb=e328f97c4ffc895f4620d14904d0af8534b009f6;p=supertux.git diff --git a/src/badguy/livefire.cpp b/src/badguy/livefire.cpp index 955fad06b..55c91ad6e 100644 --- a/src/badguy/livefire.cpp +++ b/src/badguy/livefire.cpp @@ -23,16 +23,14 @@ #include "supertux/object_factory.hpp" #include "supertux/sector.hpp" -static const float WALKSPEED = 80; -static const float MAXDROPHEIGHT = 20; - LiveFire::LiveFire(const Reader& reader) : WalkingBadguy(reader, "images/creatures/livefire/livefire.sprite", "left", "right"), - lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-medium.sprite")), - state(STATE_WALKING) + lightsprite(SpriteManager::current()->create("images/objects/lightmap_light/lightmap_light-medium.sprite")), + death_sound("sounds/fall.wav"), + state(STATE_WALKING) { - walk_speed = WALKSPEED; - max_drop_height = MAXDROPHEIGHT; + walk_speed = 80; + max_drop_height = 20; lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE)); lightsprite->set_color(Color(1.0f, 0.9f, 0.8f)); } @@ -59,12 +57,16 @@ LiveFire::collision_badguy(BadGuy& badguy, const CollisionHit& hit) void LiveFire::active_update(float elapsed_time) { + // Remove when extinguish animation is done + if((sprite->get_action() == "extinguish-left" || sprite->get_action() == "extinguish-right" ) + && sprite->animation_done()) remove_me(); + if(state == STATE_WALKING) { WalkingBadguy::active_update(elapsed_time); return; } - if(state == STATE_SLEEPING) { + if(state == STATE_SLEEPING && get_group() == COLGROUP_MOVING) { Player* player = this->get_nearest_player(); if (player) { @@ -82,19 +84,16 @@ LiveFire::active_update(float elapsed_time) { state = STATE_WAKING; } } - - BadGuy::active_update(elapsed_time); } - - if(state == STATE_WAKING) { + else if(state == STATE_WAKING) { if(sprite->animation_done()) { // start walking state = STATE_WALKING; WalkingBadguy::initialize(); } - - BadGuy::active_update(elapsed_time); } + + BadGuy::active_update(elapsed_time); } void @@ -113,6 +112,7 @@ void LiveFire::freeze() { // attempting to freeze a flame causes it to go out + death_sound = "sounds/sizzle.ogg"; kill_fall(); } @@ -131,19 +131,20 @@ LiveFire::is_flammable() const void LiveFire::kill_fall() { - //TODO: get unique sound for ice-fire encounters - sound_manager->play("sounds/fall.wav", get_pos()); + SoundManager::current()->play(death_sound, get_pos()); // throw a puff of smoke 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)); // extinguish the flame - sprite->set_action(dir == LEFT ? "extinguish-left" : "extinguish-right"); + sprite->set_action(dir == LEFT ? "extinguish-left" : "extinguish-right", 1); physic.set_velocity_y(0); physic.set_acceleration_y(0); physic.enable_gravity(false); - set_state(STATE_SQUISHED); // used to nullify any threat and remove + lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE)); + lightsprite->set_color(Color(0.5f, 0.4f, 0.3f)); + set_group(COLGROUP_DISABLED); // start dead-script run_dead_script();