X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fbadguy%2Fyeti.cpp;h=1c039068e459d39655fe99e5509964d354e5e3dd;hb=013a5ca196545a094f27c1b708facd0084d58d55;hp=f358b798f31cbb21e7347bb4d92b952b53506e63;hpb=41942dc7816efe29e98a4ef51553c883eab20e85;p=supertux.git diff --git a/src/badguy/yeti.cpp b/src/badguy/yeti.cpp index f358b798f..1c039068e 100644 --- a/src/badguy/yeti.cpp +++ b/src/badguy/yeti.cpp @@ -59,7 +59,7 @@ Yeti::Yeti(const lisp::Lisp& reader) countMe = false; sound_manager->preload("sounds/yeti_gna.wav"); sound_manager->preload("sounds/yeti_roar.wav"); - draw_dead_script_hint = false; + hud_head.reset(new Surface("images/creatures/yeti/hudlife.png")); } Yeti::~Yeti() @@ -67,7 +67,7 @@ Yeti::~Yeti() } void -Yeti::activate() +Yeti::initialize() { dir = RIGHT; jump_down(); @@ -80,10 +80,32 @@ Yeti::draw(DrawingContext& context) if(safe_timer.started() && size_t(game_time*40)%2) return; + draw_hit_points(context); + BadGuy::draw(context); } void +Yeti::draw_hit_points(DrawingContext& context) +{ + int i; + + Surface *hh = hud_head.get(); + if (!hh) + return; + + context.push_transform(); + context.set_translation(Vector(0, 0)); + + for (i = 0; i < hit_points; ++i) + { + context.draw_surface(hh, Vector(BORDER_X + (i * hh->get_width()), BORDER_Y + 1), LAYER_FOREGROUND1); + } + + context.pop_transform(); +} + +void Yeti::active_update(float elapsed_time) { switch(state) { @@ -197,7 +219,7 @@ void Yeti::take_hit(Player& ) state = SQUISHED; state_timer.start(SQUISH_TIME); - set_group(COLGROUP_MOVING_ONLY_STATIC); + set_colgroup_active(COLGROUP_MOVING_ONLY_STATIC); sprite->set_action("dead"); if (countMe) Sector::current()->get_level()->stats.badguys++; @@ -216,7 +238,7 @@ void Yeti::kill_fall() { // shooting bullets or being invincible won't work :) - take_hit(*get_nearest_player()); // FIXME: debug only(?) + //take_hit(*get_nearest_player()); // FIXME: debug only(?) } void @@ -234,7 +256,7 @@ void Yeti::drop_stalactite() { // make a stalactite falling down and shake camera a bit - Sector::current()->camera->shake(.1, 0, 10); + Sector::current()->camera->shake(.1f, 0, 10); YetiStalactite* nearest = 0; float dist = FLT_MAX;