--- a/src/PhysicsObject.cc Sun Dec 07 21:10:04 2008 +0000
+++ b/src/PhysicsObject.cc Sun Dec 07 21:18:09 2008 +0000
@@ -5,7 +5,7 @@
#include <cmath>
PhysicsObject::PhysicsObject (PhysicsWorld &world, float mass, Vector position, Vector velocity, bool enabled) :
- world(world), position(position), velocity(velocity), mass(mass), inAir(true), aim(0), facingRight(true),
+ world(world), position(position), velocity(velocity), mass(mass), inAir(true), aim(0), facing(FACING_RIGHT),
alive(false), shouldDelete(false), pivot(NULL)
{
if (enabled)
@@ -300,16 +300,15 @@
//Engine::log(DEBUG, "PhysicsObject.changeAim") << "Player aim: " << this->aim;
}
-void PhysicsObject::setFacing(bool facingRight) {
- //Engine::log(DEBUG, "PhysicsObject.setFacing") << "Facing: " << right;
- this->facingRight = facingRight;
+void PhysicsObject::setFacing (FacingDirection facing) {
+ this->facing = facing;
}
-void PhysicsObject::updatePhysics (Vector position, Vector velocity, bool inAir, bool facingRight, float aim) {
+void PhysicsObject::updatePhysics (Vector position, Vector velocity, bool inAir, FacingDirection facing, float aim) {
this->position = position;
this->velocity = velocity;
this->inAir = inAir;
- this->facingRight = facingRight;
+ this->facing = facing;
this->aim = aim;
}
@@ -325,8 +324,8 @@
return velocity;
}
-bool PhysicsObject::getFacing (void) const {
- return facingRight;
+FacingDirection PhysicsObject::getFacing (void) const {
+ return facing;
}
float PhysicsObject::getAim (void) const {
@@ -334,7 +333,7 @@
}
Vector PhysicsObject::getDirection (void) const {
- return facingRight ? Vector(cos(aim), -sin(aim)) : Vector(-cos(aim), -sin(aim));
+ return facing == FACING_RIGHT ? Vector(cos(aim), -sin(aim)) : Vector(-cos(aim), -sin(aim));
}
const std::vector<Vector>& PhysicsObject::getShape () const {
@@ -392,31 +391,7 @@
}
}
-float PhysicsObject::getPivotForce (PhysicsObject *bob) { return 0.0; }
-
-void PhysicsObject::draw(CL_GraphicContext *gc) {
- CL_Quad player(
- (position+shape[0]).x, (position+shape[0]).y,
- (position+shape[1]).x, (position+shape[1]).y,
- (position+shape[2]).x, (position+shape[2]).y,
- (position+shape[3]).x, (position+shape[3]).y
- );
-
- gc->fill_quad(player, CL_Color::green);
-
- const uint16_t chlen = 10;
- uint16_t x = player.center().x;
- uint16_t y = player.center().y;
- if (facingRight) {
- gc->draw_line(x, y,
- x + std::cos(aim)*chlen,
- y - std::sin(aim)*chlen,
- CL_Color::black);
- } else {
- gc->draw_line(x, y,
- x - std::cos(aim)*chlen,
- y - std::sin(aim)*chlen,
- CL_Color::black);
- }
+float PhysicsObject::getPivotForce (PhysicsObject *bob) {
+ return 0.0;
}