Ei se viel? k??nny kun on sienestetty.
authorsaiam
Mon, 24 Nov 2008 21:24:17 +0000
changeset 98 606c419e42a7
parent 97 2e7c8ab485de
child 99 c9b96dcfe4ee
Ei se viel? k??nny kun on sienestetty.
src/proto2/Physics.cc
src/proto2/Physics.hh
--- a/src/proto2/Physics.cc	Mon Nov 24 21:08:36 2008 +0000
+++ b/src/proto2/Physics.cc	Mon Nov 24 21:24:17 2008 +0000
@@ -120,13 +120,13 @@
 void PhysicsObject::updatePosition () {
 
     if(!this->inAir) {
-		/*if(!forceq.empty()) {
-			if(forceq.front().y == 0) {
-         		this->position = moveVertically(forceq.front().x > 0);
-				forceq.pop();
-			}
-		} */
-		return;
+        /*if(!forceq.empty()) {
+          if(forceq.front().y == 0) {
+          this->position = moveVertically(forceq.front().x > 0);
+          forceq.pop();
+          }
+          } */
+        return;
 	}
 	// TODO HERE
 
@@ -293,12 +293,15 @@
  */
 int getDirectionIndex (Vector dir) {
 	int index = 0;
-	if(dir.x < -0.1 || (dir.y > 0.1 && dir.x < 0.1))
+	if(dir.x < -0.1 || (dir.y > 0.1 && dir.x < 0.1)) {
 		index += 4;
+        }
 	if((dir.x > 0.1 && dir.y > 0.1) || (dir.y > 0.1 && dir.x < 0.1)) {
 		index += 2;
-	if(!(dir.x > -0.1 && dir < 0.1) && !(dir.y < 0.1 && dir.y > -0.1)) {
+        }
+	if(!(dir.x > -0.1 && dir.y < 0.1) && !(dir.y < 0.1 && dir.y > -0.1)) {
 		index += 1;
+        }
 	return index;
 }
 
@@ -323,10 +326,10 @@
 		else
 			break;
 	}
-    frees.push_back(DIRECTION[dirIdx]);
+    frees.push_back(DIRECTIONS[dirIdx]);
 
 	Vector normal(0,0);
-	for(int i = 0; i < size(); i++) {
+	for(int i = 0; i < frees.size(); i++) {
 		normal += frees[i];
 	}
 	return normal;
--- a/src/proto2/Physics.hh	Mon Nov 24 21:08:36 2008 +0000
+++ b/src/proto2/Physics.hh	Mon Nov 24 21:24:17 2008 +0000
@@ -48,6 +48,8 @@
     void generateTerrain (int seed);
     bool collided (Vector oldPos, Vector newPos);
 
+    Vector getNormal(Vector hitPoint, Vector prevPoint);
+
     TerrainType getType(Vector pos) const;
 };
 
@@ -92,12 +94,17 @@
      *
      * @return new position
      */
-	Vector walk (bool right);
+    Vector walk (bool right);
 
     /**
      * Handle ground-jumping
      */
-	void jump (void);
+    void jump (void);
+
+    /**
+     * Handle ground-bounce
+     */
+    void bounce (Vector normal);
 
 private:
     void updatePosition (void);