pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src pingu_action.cxx,1.17,1.18 vector.cxx


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src pingu_action.cxx,1.17,1.18 vector.cxx,1.2,1.3 vector.hxx,1.2,1.3
Date: 3 Nov 2002 22:20:31 -0000

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

Modified Files:
        pingu_action.cxx vector.cxx vector.hxx 
Log Message:
added alternative move_with_forces implementation

Index: pingu_action.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingu_action.cxx,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- pingu_action.cxx    3 Nov 2002 20:30:38 -0000       1.17
+++ pingu_action.cxx    3 Nov 2002 22:20:29 -0000       1.18
@@ -17,6 +17,7 @@
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
+#include <iostream>
 #include <assert.h>
 #include <math.h>
 #include "vector.hxx"
@@ -106,6 +107,52 @@
 {
   // Apply gravity
   pingu->set_velocity(pingu->get_velocity() + Vector(0.0f, 1.0f));
+
+#if 0
+  Vector pos        = pingu->get_pos();
+  Vector target_pos = pos + pingu->get_velocity();
+  Vector dir        = target_pos - pingu->get_pos();
+  Vector velocity   = pingu->get_velocity();
+
+  float length = dir.length();
+  dir.normalize();
+
+  for(float i = 0; i < length; ++i)
+    {
+      pingu->set_pos(pos + (dir * i));
+
+      // If there is something below the Pingu
+      if (rel_getpixel(0, -1) != Groundtype::GP_NOTHING)
+        {
+          // FIXME: this shouldn't be really here, but its a
+          // FIXME: quick&dirty way to kill falling pingus
+          if (velocity.y > Actions::Faller::deadly_velocity+1)
+            {
+              //std::cout << "Velocity: " << velocity << std::endl;
+              pingu->set_action(Actions::Splashed);
+              return;
+            }
+          else
+            {
+              // Make it so that the Pingu won't go down any further.
+              pingu->set_velocity(Vector(0, 0));
+              return;
+            }
+        }
+      else if (head_collision_on_walk(0, 1))
+        {
+          return;
+        }
+      else if (collision_on_walk(1, 0))
+        {
+          // Make the Pingu bounce off the wall
+          velocity.x = -velocity.x / 3.0f;
+          pingu->set_velocity(velocity);
+          pingu->direction.change();
+          return;
+        }
+    }
+#else
     
   // FIXME: What does this variable do?
   Vector resultant_force = pingu->get_velocity();
@@ -142,9 +189,9 @@
 
   // Keep moving the Pingu until there is only a fraction left
   while (   force_counter.x <= -1 
-         || force_counter.x >=  1
-         || force_counter.y <= -1
-         || force_counter.y >=  1)
+            || force_counter.x >=  1
+            || force_counter.y <= -1
+            || force_counter.y >=  1)
     {
       x_numerator += x_inc;
 
@@ -225,7 +272,7 @@
            }
        }
     }
-
+#endif
 }
 
 /* EOF */

Index: vector.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/vector.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- vector.cxx  15 Oct 2002 19:13:32 -0000      1.2
+++ vector.cxx  3 Nov 2002 22:20:29 -0000       1.3
@@ -106,6 +106,12 @@
     }
 }
 
+float
+Vector::length() const
+{
+  return sqrt(x * x + y * y + z * z);
+}
+
 Vector
 Vector::rotate (float angle, const Vector& pos) const
 {

Index: vector.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/vector.hxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- vector.hxx  15 Oct 2002 19:13:32 -0000      1.2
+++ vector.hxx  3 Nov 2002 22:20:29 -0000       1.3
@@ -47,6 +47,8 @@
   Vector& operator*= (      float   mul);
   
   void normalize ();
+
+  float length() const;
   
   Vector rotate (float angle, const Vector& pos) const;
 





reply via email to

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