commented walk
authornireco
Tue, 02 Dec 2008 00:47:14 +0000
changeset 176 9e4e272c2ec6
parent 175 c4a6af377a1a
child 177 fb144e957c3a
commented walk
src/proto2/Physics.cc
--- a/src/proto2/Physics.cc	Tue Dec 02 00:24:01 2008 +0000
+++ b/src/proto2/Physics.cc	Tue Dec 02 00:47:14 2008 +0000
@@ -42,19 +42,28 @@
     world.addObject(this);
 }
 
+/**
+ * Player walks on floor.
+ */
 Vector PhysicsObject::walk (bool right) {
-    float deltaX = right ? 1 : -1;
+    float deltaX = right ? 1 : -1; // which way we are walking
     Vector reached = this->position;
    
+    // Is there upward ramp
     if(!possibleLocation(position+Vector(deltaX, 0))) {
+        // Yes. Then we check n pixels up
         for(int i = 1; i < 3; i++) {
             if(possibleLocation(position+Vector(deltaX, -i))) {
+                // and when there is finally EMPTY, we can walk
                 reached = position+Vector(deltaX, -i);
                 break;
             }
         }
     } else {
+       // Or downward ramp
        for(int i = 0; i < 3; i++) {
+            // And when there is finally ground we can step on it
+            // If there is no gound we still step there, but will fall down
             if(possibleLocation(position+Vector(deltaX, i))) {
                 reached = position+Vector(deltaX, i);
             } else {
@@ -62,6 +71,7 @@
             }
         }
     }
+    // And we return where we got
     return reached;
  
 }