Index: Games/Pingus/src/actions/bridger.cxx =================================================================== RCS file: /usr/local/cvsroot/Games/Pingus/src/actions/bridger.cxx,v retrieving revision 1.16 diff -u -r1.16 bridger.cxx --- Games/Pingus/src/actions/bridger.cxx 16 Sep 2002 20:31:09 -0000 1.16 +++ Games/Pingus/src/actions/bridger.cxx 22 Sep 2002 14:02:23 -0000 @@ -32,6 +32,9 @@ namespace Actions { +// Initialise class static +const int Bridger::brick_length = 16; + bool Bridger::static_surfaces_loaded = false; CL_Surface Bridger::brick_l; CL_Surface Bridger::brick_r; @@ -61,8 +64,6 @@ "pingus", 15.0f, Sprite::NONE, Sprite::ONCE); build_sprite.set_align_center_bottom (); walk_sprite.set_align_center_bottom (); - - last_pos = pingu->get_pos(); } void @@ -118,8 +119,6 @@ update_walk (delta); break; } - - last_pos = pingu->get_pos(); } void @@ -138,7 +137,6 @@ { pingu->direction.change (); pingu->set_action (Actions::Walker); - pingu->set_pos(last_pos); return; } } @@ -159,7 +157,14 @@ if (bricks > 0) { - place_a_brick(); + if (brick_placement_allowed()) + place_a_brick(); + else + { + pingu->direction.change (); + pingu->set_action (Actions::Walker); + return; + } } else // Out of bricks { @@ -177,9 +182,27 @@ bool Bridger::way_is_free() { - return (rel_getpixel(4,2) == Groundtype::GP_NOTHING) - && !head_collision_on_walk(4, 2) - && !head_collision_on_walk(8, 4); + return (rel_getpixel(4,2) == Groundtype::GP_NOTHING); +} + +bool +Bridger::brick_placement_allowed(void) +{ + bool brick_allowed = true; + + // Don't allow a brick to be placed if a Pingu would have a head collision + // if it walked along the whole of the brick. Otherwise the Pingu, + // especially a walker, could get stuck between the brick and the ceiling. + for (int x_inc = 1; x_inc <= brick_length; ++x_inc) + { + if (head_collision_on_walk(x_inc, 2)) + { + brick_allowed = false; + break; + } + } + + return brick_allowed; } void Index: Games/Pingus/src/actions/bridger.hxx =================================================================== RCS file: /usr/local/cvsroot/Games/Pingus/src/actions/bridger.hxx,v retrieving revision 1.11 diff -u -r1.11 bridger.hxx --- Games/Pingus/src/actions/bridger.hxx 10 Sep 2002 19:24:19 -0000 1.11 +++ Games/Pingus/src/actions/bridger.hxx 22 Sep 2002 14:02:23 -0000 @@ -39,6 +39,8 @@ GameCounter counter; + static const int brick_length; + static bool static_surfaces_loaded; static CL_Surface static_surface; static CL_Surface brick_l; @@ -49,8 +51,6 @@ //int do_steps; bool block_build; - CL_Vector last_pos; - std::string name; public: Bridger(); @@ -66,6 +66,7 @@ void draw (GraphicContext& gc); bool way_is_free (); + bool brick_placement_allowed (void); void place_a_brick (); void walk_one_step_up ();