From: Tobias Markus Date: Sat, 10 Aug 2013 19:45:02 +0000 (-1000) Subject: Allow butt-jumping on infoblocks X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=c3298cf8f0be2b4a307f7e162c52881705687ae5;p=supertux.git Allow butt-jumping on infoblocks --- diff --git a/src/object/infoblock.cpp b/src/object/infoblock.cpp index 3d262dfb2..f1e6e04e2 100644 --- a/src/object/infoblock.cpp +++ b/src/object/infoblock.cpp @@ -94,6 +94,17 @@ InfoBlock::hit(Player& player) } } +HitResponse +InfoBlock::collision(GameObject& other, const CollisionHit& hit){ + + Player* player = dynamic_cast (&other); + if (player) { + if (player->does_buttjump) + InfoBlock::hit(*player); + } + return Block::collision(other, hit); +} + Player* InfoBlock::get_nearest_player() { @@ -115,7 +126,7 @@ InfoBlock::update(float delta) 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) { @@ -123,7 +134,7 @@ InfoBlock::update(float delta) 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; } } diff --git a/src/object/infoblock.hpp b/src/object/infoblock.hpp index 91ae5baf0..864856627 100644 --- a/src/object/infoblock.hpp +++ b/src/object/infoblock.hpp @@ -33,6 +33,7 @@ public: protected: virtual void hit(Player& player); + virtual HitResponse collision(GameObject& other, const CollisionHit& hit); Player* get_nearest_player(); protected: