#include "sprite/sprite_manager.hpp"
#include "supertux/object_factory.hpp"
#include "supertux/sector.hpp"
+#include "supertux/info_box_line.hpp"
#include "util/reader.hpp"
#include "video/drawing_context.hpp"
+#include "sprite/sprite.hpp"
namespace {
const float SCROLL_DELAY = 0.5;
}
InfoBlock::InfoBlock(const Reader& lisp) :
- Block(sprite_manager->create("images/objects/bonus_block/infoblock.sprite")),
+ Block(SpriteManager::current()->create("images/objects/bonus_block/infoblock.sprite")),
message(),
- shown_pct(0),
+ shown_pct(0),
dest_pct(0),
lines(),
lines_height()
}
}
+HitResponse
+InfoBlock::collision(GameObject& other, const CollisionHit& hit_)
+{
+ Player* player = dynamic_cast<Player*> (&other);
+ if (player)
+ {
+ if (player->does_buttjump)
+ InfoBlock::hit(*player);
+ }
+ return Block::collision(other, hit_);
+}
+
Player*
InfoBlock::get_nearest_player()
{
if (delta == 0) return;
- // hide message if player is too far away or above infoblock
+ // hide message if player is too far away
if (dest_pct > 0) {
Player* player = get_nearest_player();
if (player) {
Vector p2 = player->get_pos() + (player->get_bbox().p2 - player->get_bbox().p1) / 2;
Vector dist = (p2 - p1);
float d = dist.norm();
- if (d > 128 || dist.y < 0) dest_pct = 0;
+ if (d > 128) dest_pct = 0;
}
}
break;
}
- lines[i]->draw(context, Rect(x1, y, x2, y), LAYER_GUI-50+1);
+ lines[i]->draw(context, Rectf(x1, y, x2, y), LAYER_GUI-50+1);
y += lines[i]->get_height();
}
dest_pct = 0;
}
-IMPLEMENT_FACTORY(InfoBlock, "infoblock");
-
/* EOF */