Commit | Line | Data |
---|---|---|
2c18685d | 1 | #include "Screen.h" |
2c18685d PG |
2 | |
3 | #include "../Entities/PhysicsEntity.h" | |
094a13b8 | 4 | #include "../Entities/Ball.h" |
2c18685d | 5 | |
617dcc71 PG |
6 | |
7 | /// ***** Constructors/Destructors ***** | |
8 | ||
2c18685d PG |
9 | Screen::Screen() |
10 | { | |
11 | ||
12 | } | |
13 | Screen::~Screen() | |
14 | { | |
15 | ||
16 | } | |
17 | ||
617dcc71 PG |
18 | /// ***** Public Class Methods ***** |
19 | ||
2c18685d PG |
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 | ||
094a13b8 PG |
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) | |
2c18685d | 34 | acc.y += velo.y * -2; |
2c18685d | 35 | |
094a13b8 | 36 | if(pos.y < 0+radius && velo.y < 0) |
2c18685d | 37 | acc.y += velo.y * -2; |
2c18685d | 38 | |
094a13b8 | 39 | if(pos.x > 800-radius && velo.x > 0) |
2c18685d | 40 | acc.x += velo.x * -2; |
2c18685d | 41 | |
094a13b8 | 42 | if(pos.x < 0+radius && velo.x < 0) |
2c18685d | 43 | acc.x += velo.x * -2; |
2c18685d PG |
44 | |
45 | return acc; | |
46 | } |