removed tabs from Physics.cc
authornireco
Thu, 20 Nov 2008 17:23:01 +0000
changeset 76 577f248b03b4
parent 75 f2c79f2d9384
child 77 98dc9008d15f
removed tabs from Physics.cc
src/proto2/Physics.cc
--- a/src/proto2/Physics.cc	Thu Nov 20 17:14:59 2008 +0000
+++ b/src/proto2/Physics.cc	Thu Nov 20 17:23:01 2008 +0000
@@ -19,9 +19,9 @@
 void PhysicsWorld::tick () {
 //    Engine::log(DEBUG, "physics.apply_force") << "*tick*";
 
-	for (std::vector<PhysicsObject*>::iterator i = objects.begin(); i != objects.end(); i++) {
-       	(*i)->tick(); 
-  	}
+    for (std::vector<PhysicsObject*>::iterator i = objects.begin(); i != objects.end(); i++) {
+        (*i)->tick(); 
+    }
 }
 
 PhysicsObject::PhysicsObject (PhysicsWorld &world, float mass, Vector position, Vector velocity)
@@ -32,14 +32,14 @@
     
 void PhysicsObject::updatePosition () {
 
-	// Check if the player is moving on the ground
-	/*if (this->velocity.y == 0 && (position.y >= world.dimensions.y - 3)) {
-    	position.x += 50 * velocity.x * (PHYSICS_TICK_MS / 1000.0);
-		velocity.x = 0;
-		return;
-	}*/
+    // Check if the player is moving on the ground
+    /*if (this->velocity.y == 0 && (position.y >= world.dimensions.y - 3)) {
+        position.x += 50 * velocity.x * (PHYSICS_TICK_MS / 1000.0);
+        velocity.x = 0;
+        return;
+    }*/
 
-	// If not moving on the ground, apply normal physics
+    // If not moving on the ground, apply normal physics
 
     // Calculate gravity's influence on the velocity vector
     this->velocity += world.gravity * (PHYSICS_TICK_MS / 1000.0);
@@ -55,11 +55,11 @@
     if (newPosition.x < 0 || (newPosition.x > world.dimensions.x)) {
         // CRASH!
         this->velocity.x *= -0.5;
-		
-		// If the velocity drops under some fixed constant we decide it is zero.
-		// This is to prevent the object from bouncing eternally.
-		if (abs(this->velocity.x) < 0.1)
-			this->velocity.x = 0;
+        
+        // If the velocity drops under some fixed constant we decide it is zero.
+        // This is to prevent the object from bouncing eternally.
+        if (abs(this->velocity.x) < 0.1)
+            this->velocity.x = 0;
 
         collided = true;
     } else {
@@ -67,23 +67,23 @@
     }
     
     if (newPosition.y <= 0 || (newPosition.y >= world.dimensions.y)) {
-		this->velocity.y *= -0.3;
+        this->velocity.y *= -0.3;
 
-		
+
  
-		if (abs(this->velocity.y) < 0.1) {
-			this->velocity.y = 0;
-			// Static friction
-			this->velocity.x *= 0.95;
-		} else {
-        	// Kinetic friction
-			this->velocity.x *= 0.75;
-		}
+        if (abs(this->velocity.y) < 0.1) {
+            this->velocity.y = 0;
+            // Static friction
+            this->velocity.x *= 0.95;
+        } else {
+            // Kinetic friction
+            this->velocity.x *= 0.75;
+        }
 
         collided = true;
-	} else {
+    } else {
         this->position.y = newPosition.y;
-	}
+    }
     
     if(!collided) {
         this->position = newPosition;
@@ -91,22 +91,22 @@
 }
 
 bool PhysicsWorld::collided (Vector oldPos, Vector newPos) {
-	int deltaX = oldPos.x - newPos.x; 
-	int deltaY = oldPos.y - newPos.y; 
-	double distance = sqrt(deltaX * deltaX + deltaY * deltaY);
-	double xInc = (double) deltaX / distance;
-	double yInc = (double) deltaY / distance;
+    int deltaX = oldPos.x - newPos.x; 
+    int deltaY = oldPos.y - newPos.y; 
+    double distance = sqrt(deltaX * deltaX + deltaY * deltaY);
+    double xInc = (double) deltaX / distance;
+    double yInc = (double) deltaY / distance;
     double currentX = oldPos.x;
     double currentY = oldPos.y;
 
-	// This implementation is bit slow since it checks some squares twice.
+    // This implementation is bit slow since it checks some squares twice.
     for(unsigned int i = 1; i < distance; i++) {
-		currentX += xInc;
-		currentY += yInc;
-		if(terrain[(int)currentX][(int)currentY] != EMPTY)
-			return false;
-	}
-	return true;
+        currentX += xInc;
+        currentY += yInc;
+        if(terrain[(int)currentX][(int)currentY] != EMPTY)
+            return false;
+    }
+    return true;
 }
 
 void PhysicsObject::integrate(Vector force, uint16_t dt) {