It's like so cool.
--- a/src/proto2/Physics.cc Tue Nov 18 18:00:32 2008 +0000
+++ b/src/proto2/Physics.cc Tue Nov 18 18:21:32 2008 +0000
@@ -6,50 +6,50 @@
PhysicsWorld::PhysicsWorld (Vector dimensions) : dimensions(dimensions) {}
void PhysicsWorld::addObject (PhysicsObject *object) {
- objects.push_back(object);
+ objects.push_back(object);
}
void PhysicsWorld::tick () {
- std::for_each(objects.begin(), objects.end(), /*TODO: tick*/);
+ std::for_each(objects.begin(), objects.end(), /*TODO: tick*/);
}
PhysicsObject::PhysicsObject (mass, position, velocity, force)
- : mass(mass), position(position), velocity(velocity), force(force) {}
+ : mass(mass), position(position), velocity(velocity), force(force) {}
void PhysicsObject::updatePosition () {
- // Calculate gravity's influence on the velocity vector
- this->velocity += GRAVITY_FORCEi / mass * 1.0i / mass * 1.0ff;
-
- Vector newPosition = position + velocity * PHYSICS_TICK_MS;
+ // Calculate gravity's influence on the velocity vector
+ this->velocity += GRAVITY_FORCEi / mass * 1.0i / mass * 1.0ff;
+
+ Vector newPosition = position + velocity * PHYSICS_TICK_MS;
- //TODO Handle the object as a square or a polygon
- if(newPosition.x < 0 || (newPosition.x > PHYSICS_WORLD_WIDTH)
- || (newPosition.y < 0) || (newPosition.y >= PHYSICS_WORLD_HEIGHT)) {
-
- // CRASH!
- this->velocity *= -1;
- } else {
- this->position = newPosition;
- }
+ //TODO Handle the object as a square or a polygon
+ if(newPosition.x < 0 || (newPosition.x > PHYSICS_WORLD_WIDTH)
+ || (newPosition.y < 0) || (newPosition.y >= PHYSICS_WORLD_HEIGHT)) {
+
+ // CRASH!
+ this->velocity *= -1;
+ } else {
+ this->position = newPosition;
+ }
}
void PhysicsObject::applyForce (Vector force) {
- this->velocity += force / mass * 1.0f; // The last factor denotes the time.
- // It should be scaled somehow.
+ this->velocity += force / mass * 1.0f; // The last factor denotes the time.
+ // It should be scaled somehow.
}
void PhysicsObjectu::updatePhysics (Vector position, Vector velocity, Vector force) {
- this->position = position;
- this->velocity = velocity;
- this->force = force;
+ this->position = position;
+ this->velocity = velocity;
+ this->force = force;
}
Vector PhysicsObject::getPosition () {
- return this->position;
+ return this->position;
}
void PhysicsObject::tick () {
- this->updatePosition();
+ this->updatePosition();
}
--- a/src/proto2/Vector.hh Tue Nov 18 18:00:32 2008 +0000
+++ b/src/proto2/Vector.hh Tue Nov 18 18:21:32 2008 +0000
@@ -3,15 +3,6 @@
#include <complex>
-/**
- * A vector class. This class implements standard vector operations
- * for a two dimensional vector. It uses STL complex number class
- * internally.
- */
-class Vector {
- std::complex vector(0,0);
-
-
-};
+typedef Vector std::complex<float>;
#endif