From: Ricardo Cruz Date: Thu, 23 Sep 2004 17:47:49 +0000 (+0000) Subject: Show a message when more than one bad guys is killed in a row. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=3e184f18f1b19c8884d3899f20eeda37a2916290;p=supertux.git Show a message when more than one bad guys is killed in a row. SVN-Revision: 1960 --- diff --git a/src/gameobjs.cpp b/src/gameobjs.cpp index b440b5cc1..1ace86caa 100644 --- a/src/gameobjs.cpp +++ b/src/gameobjs.cpp @@ -114,7 +114,7 @@ BouncyBrick::draw(DrawingContext& context) draw_tile(context, shape.id, position + Vector(0, offset), LAYER_TILES+1); } -FloatingText::FloatingText(const Vector& pos, std::string& text_) +FloatingText::FloatingText(const Vector& pos, const std::string& text_) : position(pos), text(text_) { timer.start(1000); diff --git a/src/gameobjs.h b/src/gameobjs.h index 88a8d7aab..197273f0a 100644 --- a/src/gameobjs.h +++ b/src/gameobjs.h @@ -94,7 +94,7 @@ private: class FloatingText : public GameObject { public: - FloatingText(const Vector& pos, std::string& text_); + FloatingText(const Vector& pos, const std::string& text_); FloatingText(const Vector& pos, int s); // use this for score, for instance virtual void action(float elapsed_time); diff --git a/src/player.cpp b/src/player.cpp index 87cfc3bf6..75f622cfb 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -22,6 +22,7 @@ #include #include "app/globals.h" +#include "app/gettext.h" #include "player.h" #include "defines.h" #include "scene.h" @@ -334,7 +335,15 @@ Player::action(float elapsed_time) physic.enable_gravity(false); /* Reset score multiplier (for multi-hits): */ if (!invincible_timer.started()) + { + if(player_status.score_multiplier > 2) + { // show a message + char str[124]; + sprintf(str, _("%d bad guys in a row!"), player_status.score_multiplier-1); + Sector::current()->add_floating_text(base, str); + } player_status.score_multiplier = 1; + } } if(jumped_in_solid) diff --git a/src/sector.cpp b/src/sector.cpp index 017eff714..316b22f26 100644 --- a/src/sector.cpp +++ b/src/sector.cpp @@ -756,6 +756,12 @@ Sector::add_particles(const Vector& epicenter, const Vector& velocity, const Vec return true; } +void +Sector::add_floating_text(const Vector& pos, const std::string& text) +{ + add_object(new FloatingText(pos, text)); +} + /* Break a brick: */ bool Sector::trybreakbrick(const Vector& pos, bool small) diff --git a/src/sector.h b/src/sector.h index 4485f0572..7b6c6cab2 100644 --- a/src/sector.h +++ b/src/sector.h @@ -113,6 +113,7 @@ public: bool add_bullet(const Vector& pos, float xm, Direction dir); bool add_smoke_cloud(const Vector& pos); bool add_particles(const Vector& epicenter, const Vector& velocity, const Vector& acceleration, int number, Color color, int size, int life_time); + void add_floating_text(const Vector& pos, const std::string& text); /** Try to grab the coin at the given coordinates */ void trygrabdistro(const Vector& pos, int bounciness); @@ -190,7 +191,7 @@ private: int distro_counter; bool counting_distros; - int currentmusic; + int currentmusic; }; #endif