e280e1b2a484da9ca4091aa3c3bc8f68412acd7c
[physics.git] / src / Effects / Screen.cpp
1 #include "Screen.h"
2
3 #include "../Entities/PhysicsEntity.h"
4 #include "../Entities/Ball.h"
5
6
7 /// ***** Constructors/Destructors *****
8
9 Screen::Screen()
10 {
11
12 }
13 Screen::~Screen()
14 {
15
16 }
17
18 /// ***** Public Class Methods *****
19
20 Vector2 Screen::velocityDelta(const PhysicsEntity* e, float time_step) const
21 {
22     const Vector2& pos = e->positionRaw();
23     const Vector2& velo = e->velocityRaw();
24
25     Vector2 acc(0,0);
26
27     float radius = 0;
28     const Ball* b = dynamic_cast<const Ball*>(e);
29     if( b != NULL )
30         radius = b->getRadius();
31
32
33     if(pos.y > 600-radius && velo.y > 0)
34         acc.y += velo.y * -2;
35
36     if(pos.y < 0+radius && velo.y < 0)
37         acc.y += velo.y * -2;
38
39     if(pos.x > 800-radius && velo.x > 0)
40         acc.x += velo.x * -2;
41
42     if(pos.x < 0+radius && velo.x < 0)
43         acc.x += velo.x * -2;
44
45     return acc;
46 }