pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] CVS: Games/Pingus/src/actions basher.cxx,1.19,1.20 basher.h


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src/actions basher.cxx,1.19,1.20 basher.hxx,1.12,1.13
Date: 8 Oct 2002 17:53:12 -0000

Update of /usr/local/cvsroot/Games/Pingus/src/actions
In directory dark:/tmp/cvs-serv18754

Modified Files:
        basher.cxx basher.hxx 
Log Message:
applied Gervase's basher patch

Index: basher.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/actions/basher.cxx,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- basher.cxx  5 Oct 2002 12:40:02 -0000       1.19
+++ basher.cxx  8 Oct 2002 17:53:10 -0000       1.20
@@ -96,13 +96,28 @@
 void
 Basher::walk_forward()
 {
-  if (rel_getpixel(0, -1) ==  Groundtype::GP_NOTHING) {
-    // We are in the air... lets fall...
+  int y_inc = 0;
+
+  // Find the correct y position to go to next
+  for (y_inc = 0; y_inc >= -max_steps_down; --y_inc)
+    {
+      // If there is something below, get out of this loop
+      if (rel_getpixel(0, y_inc - 1) != Groundtype::GP_NOTHING)
+       break;
+    }
+
+  if (y_inc < -max_steps_down)
+    {
+    // The step down is too much.  So stop being a Basher and be a Faller.
     pingu->set_action(Actions::Faller);
-  } else {
-    // On ground, walk forward...
-    pingu->set_x(pingu->get_x() + static_cast<int>(pingu->direction));
-  }
+    }
+  else
+    {
+    // Note that Pingu::set_pos() is the 'reverse' of the y co-ords of
+    // rel_getpixel()
+    pingu->set_pos(pingu->get_x() + static_cast<int>(pingu->direction),
+                  pingu->get_y() - y_inc);
+    }
 }
 
 bool

Index: basher.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/actions/basher.hxx,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- basher.hxx  1 Oct 2002 19:53:45 -0000       1.12
+++ basher.hxx  8 Oct 2002 17:53:10 -0000       1.13
@@ -36,6 +36,10 @@
     
   /// Defines "wall" height needed so as to determine whether it should be 
bashed.
   enum { bash_height = 4 };
+
+  /** Defines the maximum no. of steps down a Basher can go down before it
+      stops being a Basher and turns into a Faller. */
+  enum { max_steps_down = 3 };
     
 public:
   Basher ();





reply via email to

[Prev in Thread] Current Thread [Next in Thread]