Index: Pingus/src/actions/climber.cc =================================================================== RCS file: /usr/local/cvsroot/Games/Pingus/src/actions/climber.cc,v retrieving revision 1.18 diff -u -r1.18 climber.cc --- Pingus/src/actions/climber.cc 15 Dec 2001 00:56:48 -0000 1.18 +++ Pingus/src/actions/climber.cc 31 Mar 2002 22:44:27 -0000 @@ -69,9 +69,22 @@ } else if (rel_getpixel(1, 1) == ColMap::NOTHING) { - // std::cout << "Climber failed, falling down" << std::endl; - --pingu->pos.y; - pingu->pos.x += pingu->direction; + // std::cout << "Climber failed, no more wall" << std::endl; + + // If Pingu able to get to new position without head collision + if (!head_collision_on_walk(pingu->direction, 1)) + { + // Get ready to walk + --pingu->pos.y; + pingu->pos.x += pingu->direction; + } + else + { + // Get ready to fall + pingu->direction.change(); + } + + // Finish climbing. is_finished = true; } } Index: Pingus/src/PinguAction.cc =================================================================== RCS file: /usr/local/cvsroot/Games/Pingus/src/PinguAction.cc,v retrieving revision 1.21 diff -u -r1.21 PinguAction.cc --- Pingus/src/PinguAction.cc 10 Feb 2002 22:14:06 -0000 1.21 +++ Pingus/src/PinguAction.cc 31 Mar 2002 22:44:28 -0000 @@ -24,6 +24,9 @@ #include "PingusResource.hh" #include "PinguAction.hh" +// Initialise class static. +const int PinguAction::pingu_height = 26; + PinguAction::PinguAction() { is_finished = false; @@ -68,6 +71,17 @@ { assert(!"This is not a persitent action!"); return '-'; +} + +bool +PinguAction::head_collision_on_walk (int x, int y) +{ + int pixel = rel_getpixel(x, y + pingu_height); + + if (pixel != ColMap::NOTHING && !(pixel & ColMap::BRIDGE)) + return true; + + return false; } /* EOF */ Index: Pingus/src/PinguAction.hh =================================================================== RCS file: /usr/local/cvsroot/Games/Pingus/src/PinguAction.hh,v retrieving revision 1.28 diff -u -r1.28 PinguAction.hh --- Pingus/src/PinguAction.hh 10 Feb 2002 22:14:06 -0000 1.28 +++ Pingus/src/PinguAction.hh 31 Mar 2002 22:44:28 -0000 @@ -50,6 +50,9 @@ /** A pointer to the pingu, which hold the action. */ Pingu* pingu; + /// Height of Pingu. Used in head collision. + const static int pingu_height; + public: /** Indicate if the action should be canceled at the next possible point. FIXME: Only keeped public for lazyness. */ @@ -106,6 +109,9 @@ // FIXME: z_pos is currently unused for pingu actions virtual float get_z_pos () const { return 0; } + + /// True if Pingu in specified position would bang its head if it were walking + bool head_collision_on_walk (int x, int y); }; #endif /* PINGU_ACTION_HH */