From: Patrik Gornicz Date: Sat, 9 Aug 2008 17:37:30 +0000 (-0400) Subject: changed CoR to 0.8, and implemented it for the screen effect X-Git-Tag: v0.05~20 X-Git-Url: http://gitweb.pgornicz.com/gitweb.cgi?p=physics.git;a=commitdiff_plain;h=d69c6a21342e11452960f3dd9be93ff0adacea39 changed CoR to 0.8, and implemented it for the screen effect --- diff --git a/src/Effects/Screen.cpp b/src/Effects/Screen.cpp index 44cce18..85759c8 100644 --- a/src/Effects/Screen.cpp +++ b/src/Effects/Screen.cpp @@ -41,6 +41,7 @@ Vector2 Screen::velocityDelta(const PhysicsEntity* e, float time_step) const Vector2 acc(0,0); + float CoR = e->CoR; float radius = 0; const Ball* b = dynamic_cast(e); if( b != NULL ) @@ -48,16 +49,16 @@ Vector2 Screen::velocityDelta(const PhysicsEntity* e, float time_step) const if(pos.y > 600-radius && velo.y > 0) - acc.y += velo.y * -2; + acc.y += velo.y * -(1 + CoR); if(pos.y < 0+radius && velo.y < 0) - acc.y += velo.y * -2; + acc.y += velo.y * -(1 + CoR); if(pos.x > 800-radius && velo.x > 0) - acc.x += velo.x * -2; + acc.x += velo.x * -(1 + CoR); if(pos.x < 0+radius && velo.x < 0) - acc.x += velo.x * -2; + acc.x += velo.x * -(1 + CoR); return acc; } diff --git a/src/Entities/PhysicsEntity.cpp b/src/Entities/PhysicsEntity.cpp index 3354fe2..88c3525 100644 --- a/src/Entities/PhysicsEntity.cpp +++ b/src/Entities/PhysicsEntity.cpp @@ -25,7 +25,7 @@ /// ***** Constructors/Destructors ***** PhysicsEntity::PhysicsEntity(const Vector2& pos) - : Entity(pos), force(0,0), mass(1), CoR(1) + : Entity(pos), force(0,0), mass(1), CoR(0.8) { }