From d69c6a21342e11452960f3dd9be93ff0adacea39 Mon Sep 17 00:00:00 2001 From: Patrik Gornicz Date: Sat, 9 Aug 2008 13:37:30 -0400 Subject: [PATCH] changed CoR to 0.8, and implemented it for the screen effect --- src/Effects/Screen.cpp | 9 +++++---- src/Entities/PhysicsEntity.cpp | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) 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) { } -- 2.10.2