pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src/input axis_pointer.cxx,1.2,1.3 axis_p


From: torangan
Subject: [Pingus-CVS] CVS: Games/Pingus/src/input axis_pointer.cxx,1.2,1.3 axis_pointer.hxx,1.2,1.3
Date: 8 Jul 2002 14:52:06 -0000

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

Modified Files:
        axis_pointer.cxx axis_pointer.hxx 
Log Message:
- made speed configurable
- replaced CL_Vector usage with direct computation of the position delta


Index: axis_pointer.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/input/axis_pointer.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- axis_pointer.cxx    5 Jul 2002 11:02:47 -0000       1.2
+++ axis_pointer.cxx    8 Jul 2002 14:52:04 -0000       1.3
@@ -17,20 +17,20 @@
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
-#include <ClanLib/Core/Math/cl_vector.h>
+#include <math.h>
 #include "axis.hxx"
 #include "axis_pointer.hxx"
 
 namespace Input
 {
-  AxisPointer::AxisPointer(Axis* axis1, Axis* axis2) : axes(2)
+  AxisPointer::AxisPointer(float speed_, Axis* axis1, Axis* axis2) : 
speed(speed_), axes(2)
   {
     assert(axis1 && axis2);
     axes[0] = axis1;
     axes[1] = axis2;
   }
 
-  AxisPointer::AxisPointer(std::vector<Axis*> axes_) : axes(axes_)
+  AxisPointer::AxisPointer(float speed_, std::vector<Axis*> axes_) : 
speed(speed_), axes(axes_)
   {
     assert(axes.size() >= 2);
   }
@@ -57,23 +57,11 @@
   void
   AxisPointer::update(float delta)
   {
-    CL_Vector pos_delta;
-    float     x_delta(0), y_delta(0);
-    
-    for (std::vector<Axis*>::iterator it = axes.begin(); it != axes.end(); 
it++)
+    for (std::vector<Axis*>::const_iterator it = axes.begin(); it != 
axes.end(); it++)
       {
-        pos_delta.x = (*it)->get_pos();
-        pos_delta.y = 0;
-        pos_delta.z = 0;
-       
-        pos_delta.rotate((*it)->get_angle(), CL_Vector(0, 0, 1));
-      
-        x_delta += pos_delta.x;
-        y_delta += pos_delta.y;
+        x_pos += cos((*it)->get_angle()) * speed * delta;
+        y_pos += sin((*it)->get_angle()) * speed * delta;
       } 
-    
-    x_pos += x_delta * delta;
-    y_pos += y_delta * delta;
   }
 
 }

Index: axis_pointer.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/input/axis_pointer.hxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- axis_pointer.hxx    5 Jul 2002 11:02:47 -0000       1.2
+++ axis_pointer.hxx    8 Jul 2002 14:52:04 -0000       1.3
@@ -31,21 +31,23 @@
   
     private:
 
-      std::vector<Axis*> axes;      
+      const float        speed;
+      std::vector<Axis*> axes;
+           
       float              x_pos;
       float              y_pos;
       
     public:
-  
-      AxisPointer(Axis* axis1, Axis* axis2);
-      AxisPointer(std::vector<Axis*> axes_);
+
+      AxisPointer(float speed, Axis* axis1, Axis* axis2);
+      AxisPointer(float speed, std::vector<Axis*> axes_);
 
       virtual float get_x_pos ();
       virtual float get_y_pos ();
       
       virtual void  set_pos(float new_x, float new_y);
       
-      virtual void  update (float);
+      virtual void  update (float delta);
   };
 }
 




reply via email to

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