X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fobject%2Finfoblock.cpp;h=0c293c7635edd36530f35992fda077f4d8d6a136;hb=75acd4b141f45e851a492f089aa9ad24a9552409;hp=919ef9b1a8bb752f712d47c97c2c203688e93f2e;hpb=8a14d4d16329a6ad16fb7e709270a52cc16d1dfb;p=supertux.git diff --git a/src/object/infoblock.cpp b/src/object/infoblock.cpp index 919ef9b1a..0c293c763 100644 --- a/src/object/infoblock.cpp +++ b/src/object/infoblock.cpp @@ -20,6 +20,7 @@ #include #include "infoblock.hpp" + #include "game_session.hpp" #include "resources.hpp" #include "sprite/sprite_manager.hpp" @@ -29,6 +30,8 @@ #include "log.hpp" #include "object/player.hpp" #include "main.hpp" +#include "video/drawing_context.hpp" +#include "object/camera.hpp" namespace { const float SCROLL_DELAY = 0.5; @@ -68,7 +71,7 @@ InfoBlock::~InfoBlock() void InfoBlock::hit(Player& player) { - start_bounce(player.get_bbox().get_middle().x); + start_bounce(&player); //if (!stopped) { // ringing->remove_me(); @@ -154,6 +157,16 @@ InfoBlock::draw(DrawingContext& context) float x2 = (get_bbox().p1.x + get_bbox().p2.x)/2 + width/2; float y1 = original_y - height; + if(x1 < 0) { + x1 = 0; + x2 = width; + } + + if(x2 > Sector::current()->get_width()) { + x2 = Sector::current()->get_width(); + x1 = x2 - width; + } + // lines_height includes one ITEMS_SPACE too much, so the bottom border is reduced by 4px context.draw_filled_rect(Vector(x1-border, y1-border), Vector(width+2*border, height+2*border-4), Color(0.6f, 0.7f, 0.8f, 0.5f), LAYER_GUI-50);