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