--- a/src/proto2/Physics.cc Mon Nov 24 23:04:22 2008 +0000
+++ b/src/proto2/Physics.cc Mon Nov 24 23:13:19 2008 +0000
@@ -82,7 +82,10 @@
if(depth >= max) {
// We can start a free fall now
- this->inAir = true;
+ //
+ // TODO it should be set inAir if it falls from a cliff
+ //this->inAir = true;
+
// Put some speed there to make loke smoother
//this->velocity.y = -5;
return reached;
@@ -303,10 +306,10 @@
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)) {
+ if((dir.x == 1 && dir.y >= 0) || (dir.x == -1 && dir.y <= 0)) {
index += 2;
}
- if(!(dir.x > -0.1 && dir.y < 0.1) && !(dir.y < 0.1 && dir.y > -0.1)) {
+ if(dir.x != 0 && dir.y != 0) {
index += 1;
}
return index;
@@ -324,7 +327,9 @@
assert(hit != prev);
int dirIdx = getDirectionIndex(hit-prev);
- Engine::log(DEBUG, "physics.getNormal ") << dirIdx;
+ float tmp1 = hit.x-prev.x;
+ float tmp2 = hit.y-prev.y;
+ Engine::log(DEBUG, "physics.getNormal ") << dirIdx << " " << tmp1 << " " << tmp2;
for(int i = 1; i <= 2; i++) {
if(getType(hit+DIRECTIONS[(dirIdx+i) % 8]) == EMPTY)
@@ -351,6 +356,7 @@
* Bounces from straight wall in any direction.
* Direction given as normal of that wall
*/
+// TODO Bounce doesnt work kun oikealle tai vasemmalle alaviistoon mennään suoralla (tangentaalinen arvo väärän suuntainen)
void PhysicsObject::bounce (Vector normal) {
Vector tangent(normal.y, -normal.x);
Vector tprojection = tangent*(velocity * tangent) / (tangent.length()*tangent.length());
@@ -414,11 +420,11 @@
if (this->aim > PLAYER_AIM_MAX) this->aim = PLAYER_AIM_MAX;
if (this->aim < PLAYER_AIM_MIN) this->aim = PLAYER_AIM_MIN;
- Engine::log(DEBUG, "PhysicsObject.changeAim") << "Player aim: " << this->aim;
+ //Engine::log(DEBUG, "PhysicsObject.changeAim") << "Player aim: " << this->aim;
}
void PhysicsObject::setFacing(bool right) {
- Engine::log(DEBUG, "PhysicsObject.setFacing") << "Facing: " << right;
+ //Engine::log(DEBUG, "PhysicsObject.setFacing") << "Facing: " << right;
this->facing = right;
}
@@ -491,10 +497,10 @@
// loops for every pixel of circle
for(int x = std::max(0, midx-range); x < std::min((int)dimensions.x, midx+range); x++) {
for(int y = std::max(0, midy-range); y < std::min((int)dimensions.y, midy+range); y++) {
- if((x-midx) * (x-midx) + (y-midy) * (y-midy) < range*range) {
+ //if((x-midx) * (x-midx) + (y-midy) * (y-midy) < range*range) {
// and sets it to type
terrain[x][y] = type;
- }
+ //}
}
}
}