Commit | Line | Data |
---|---|---|
2c18685d PG |
1 | #include "Screen.h" |
2 | #include "../debug.h" | |
3 | ||
4 | #include "../Entities/PhysicsEntity.h" | |
094a13b8 | 5 | #include "../Entities/Ball.h" |
2c18685d PG |
6 | |
7 | Screen::Screen() | |
8 | { | |
9 | ||
10 | } | |
11 | Screen::~Screen() | |
12 | { | |
13 | ||
14 | } | |
15 | ||
2c18685d PG |
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 | ||
094a13b8 PG |
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) | |
2c18685d | 30 | acc.y += velo.y * -2; |
2c18685d | 31 | |
094a13b8 | 32 | if(pos.y < 0+radius && velo.y < 0) |
2c18685d | 33 | acc.y += velo.y * -2; |
2c18685d | 34 | |
094a13b8 | 35 | if(pos.x > 800-radius && velo.x > 0) |
2c18685d | 36 | acc.x += velo.x * -2; |
2c18685d | 37 | |
094a13b8 | 38 | if(pos.x < 0+radius && velo.x < 0) |
2c18685d | 39 | acc.x += velo.x * -2; |
2c18685d PG |
40 | |
41 | return acc; | |
42 | } |