added screen collisions using an Effect
[physics.git] / src / Effects / Screen.cpp
1 #include "Screen.h"
2 #include "../debug.h"
3
4 #include "../Entities/PhysicsEntity.h"
5
6 Screen::Screen()
7 {
8
9 }
10 Screen::~Screen()
11 {
12
13 }
14
15 Vector2 Screen::positionDelta(const PhysicsEntity*, float) const
16 {
17     return Vector2(0,0);
18 }
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     if(pos.y > 600 && velo.y > 0)
28     {
29         acc.y += velo.y * -2;
30     }
31
32     if(pos.y < 0 && velo.y < 0)
33     {
34         acc.y += velo.y * -2;
35     }
36
37     if(pos.x > 800 && velo.x > 0)
38     {
39         acc.x += velo.x * -2;
40     }
41
42     if(pos.x < 0 && velo.x < 0)
43     {
44         acc.x += velo.x * -2;
45     }
46
47     return acc;
48 }
49
50 Vector2 Screen::forceDelta(const PhysicsEntity*, float) const
51 {
52     return Vector2(0,0);
53 }