# HG changeset patch # User ekku # Date 1227564319 0 # Node ID 5cb116dc07590f25e5602e53dce483862955a5c2 # Parent dcf86a4a92b4fd79fcaa5858d577326b13c69662 Pomppii paremmin diff -r dcf86a4a92b4 -r 5cb116dc0759 src/proto2/Physics.cc --- a/src/proto2/Physics.cc Mon Nov 24 21:51:58 2008 +0000 +++ b/src/proto2/Physics.cc Mon Nov 24 22:05:19 2008 +0000 @@ -5,6 +5,7 @@ #include #include #include +#include PhysicsWorld::PhysicsWorld (Vector gravity, Vector dimensions) : tick_timer(PHYSICS_TICK_MS), gravity(gravity), dimensions(dimensions), terrain(dimensions.x, std::vector(dimensions.y, DIRT)) { @@ -179,7 +180,7 @@ reached = position + unitVector*(i-1); collided = true; this->bounce(world.getNormal(tmpVector+shape[sh], tmpVector-unitVector+shape[sh])); - this->velocity *= 0.6; + this->velocity *= 0.4; if(abs(this->velocity.x) < minVelocity && (abs(this->velocity.y) < minVelocity)) { this->inAir = false; this->velocity = Vector(0,0); @@ -313,16 +314,21 @@ std::vector frees; Vector hit = Vector((int)hitPoint.x, (int)hitPoint.y); Vector prev = Vector((int)prevPoint.x, (int)prevPoint.y); + + assert(hit != prev); + int dirIdx = getDirectionIndex(hit-prev); + Engine::log(DEBUG, "physics.getNormal ") << dirIdx; + for(int i = 1; i <= 2; i++) { - if(getType(hit+DIRECTIONS[dirIdx+i]) == EMPTY) - frees.push_back(DIRECTIONS[dirIdx+i]); + if(getType(hit+DIRECTIONS[(dirIdx+i) % 8]) == EMPTY) + frees.push_back(DIRECTIONS[(dirIdx+i) % 8]); else break; } for(int i = 1; i <= 2; i++) { - if(getType(hit+DIRECTIONS[dirIdx-i]) == EMPTY) - frees.push_back(DIRECTIONS[dirIdx-i]); + if(getType(hit+DIRECTIONS[(dirIdx-i) % 8]) == EMPTY) + frees.push_back(DIRECTIONS[(dirIdx-i) % 8]); else break; }