From: Ondřej Hošek Date: Sun, 28 Jan 2007 17:58:50 +0000 (+0000) Subject: B118: visual indication of Yeti's hitpoints. The scaled down image of the Yeti's... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=e5f99ba473f018fa9185385d96ebff0efcb2c925;p=supertux.git B118: visual indication of Yeti's hitpoints. The scaled down image of the Yeti's head is pretty ugly; please replace. SVN-Revision: 4710 --- diff --git a/data/images/creatures/yeti/hudlife.png b/data/images/creatures/yeti/hudlife.png new file mode 100644 index 000000000..517da36dc Binary files /dev/null and b/data/images/creatures/yeti/hudlife.png differ diff --git a/src/badguy/yeti.cpp b/src/badguy/yeti.cpp index 76f0faa69..5578d0d71 100644 --- a/src/badguy/yeti.cpp +++ b/src/badguy/yeti.cpp @@ -59,6 +59,7 @@ Yeti::Yeti(const lisp::Lisp& reader) countMe = false; sound_manager->preload("sounds/yeti_gna.wav"); sound_manager->preload("sounds/yeti_roar.wav"); + hud_head.reset(new Surface("images/creatures/yeti/hudlife.png")); draw_dead_script_hint = false; } @@ -80,10 +81,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) { diff --git a/src/badguy/yeti.hpp b/src/badguy/yeti.hpp index f1b750482..cfc6d055d 100644 --- a/src/badguy/yeti.hpp +++ b/src/badguy/yeti.hpp @@ -21,6 +21,8 @@ #ifndef __YETI_H__ #define __YETI_H__ +#include + #include "badguy.hpp" class Yeti : public BadGuy @@ -38,7 +40,7 @@ public: void kill_squished(GameObject& object); void kill_fall(); - virtual Yeti* clone() const { return new Yeti(*this); } + virtual Yeti* clone() const { return new Yeti((Yeti&)*this); } private: void run(); @@ -48,6 +50,8 @@ private: void summon_snowball(); void jump_down(); + void draw_hit_points(DrawingContext& context); + void take_hit(Player& player); enum YetiState { @@ -62,6 +66,7 @@ private: Timer safe_timer; int stomp_count; int hit_points; + std::auto_ptr hud_head; }; #endif