X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fbadguy%2Ftotem.cpp;h=2f1327d11b1a661f360f858279eb4bdc883fb4d5;hb=126aa9428c83eb1e17d4a75a55d15e3e6e0c6875;hp=825ed81437fd5d50adfd8a56c4f95ec9dee7e5b6;hpb=36afad72b6c66d4619372892f589a4131afed638;p=supertux.git diff --git a/src/badguy/totem.cpp b/src/badguy/totem.cpp index 825ed8143..2f1327d11 100644 --- a/src/badguy/totem.cpp +++ b/src/badguy/totem.cpp @@ -90,7 +90,7 @@ Totem::active_update(float elapsed_time) BadGuy::active_update(elapsed_time); if (!carried_by) { - if (might_fall()) + if (on_ground() && might_fall()) { dir = (dir == LEFT ? RIGHT : LEFT); activate(); @@ -151,31 +151,31 @@ Totem::collision_squished(Player& player) return true; } -HitResponse -Totem::collision_solid(GameObject& object, const CollisionHit& hit) +void +Totem::collision_solid(const CollisionHit& hit) { + update_on_ground_flag(hit); + // if we are being carried around, pass event to bottom of stack and ignore it if (carried_by) { - carried_by->collision_solid(object, hit); - return CONTINUE; + carried_by->collision_solid(hit); + return; } // If we hit something from above or below: stop moving in this direction - if (hit.normal.y != 0) { + if (hit.top || hit.bottom) { physic.set_velocity_y(0); } // If we are hit from the direction we are facing: turn around - if ((hit.normal.x > .8) && (dir == LEFT)) { + if (hit.left && (dir == LEFT)) { dir = RIGHT; activate(); } - if ((hit.normal.x < -.8) && (dir == RIGHT)) { + if (hit.right && (dir == RIGHT)) { dir = LEFT; activate(); } - - return CONTINUE; } HitResponse @@ -199,11 +199,11 @@ Totem::collision_badguy(BadGuy& badguy, const CollisionHit& hit) } // If we are hit from the direction we are facing: turn around - if ((hit.normal.x > .8) && (dir == LEFT)) { + if(hit.left && (dir == LEFT)) { dir = RIGHT; activate(); } - if ((hit.normal.x < -.8) && (dir == RIGHT)) { + if(hit.right && (dir == RIGHT)) { dir = LEFT; activate(); }