Commit | Line | Data |
---|---|---|
054d658f PG |
1 | #include "entityCreator.h" |
2 | ||
f72f4a59 PG |
3 | #include <queue> |
4 | ||
a483ed75 PG |
5 | #include "entityManager.h" |
6 | #include "Entities/Ball.h" | |
7 | #include "graphics/colors.h" | |
8 | ||
617dcc71 PG |
9 | /// ***** Private Variables ***** |
10 | ||
f72f4a59 PG |
11 | typedef std::queue<Ball*> queBall; |
12 | queBall Balls; | |
a483ed75 | 13 | |
617dcc71 | 14 | /// ***** Initializers/Cleaners ***** |
a483ed75 | 15 | |
054d658f PG |
16 | void creator::init() |
17 | { | |
f72f4a59 PG |
18 | Ball* ball; |
19 | ||
f72f4a59 PG |
20 | ball = new Ball(Vector2(50, 50), 20, cWhite); |
21 | ||
3980ceb3 | 22 | ball->applyImpulse(Vector2(0.25,0.05)), |
f72f4a59 PG |
23 | Balls.push(ball); |
24 | manager::add(ball); | |
25 | ||
26 | ball = new Ball(Vector2(100, 50), 20, cBlack); | |
27 | ||
3980ceb3 | 28 | ball->applyImpulse(Vector2(-0.15,-0.05)), |
f72f4a59 PG |
29 | Balls.push(ball); |
30 | manager::add(ball); | |
31 | ||
32 | ball = new Ball(Vector2(150, 50), 20, cGrey); | |
33 | ||
3980ceb3 | 34 | ball->applyImpulse(Vector2(0.25,0.15)), |
f72f4a59 PG |
35 | Balls.push(ball); |
36 | manager::add(ball); | |
37 | ||
38 | ball = new Ball(Vector2(50, 100), 20, cRed); | |
39 | ||
3980ceb3 | 40 | ball->applyImpulse(Vector2(0.35,-0.15)), |
f72f4a59 PG |
41 | Balls.push(ball); |
42 | manager::add(ball); | |
43 | ||
44 | ball = new Ball(Vector2(100, 100), 20, cGreen); | |
054d658f | 45 | |
094a13b8 | 46 | ball->applyImpulse(Vector2(-0.15,0.55)), |
f72f4a59 PG |
47 | Balls.push(ball); |
48 | manager::add(ball); | |
49 | ||
50 | ball = new Ball(Vector2(150, 100), 20, cBlue); | |
51 | ||
3980ceb3 | 52 | ball->applyImpulse(Vector2(0.25,0.15)), |
f72f4a59 PG |
53 | Balls.push(ball); |
54 | manager::add(ball); | |
55 | ||
56 | ball = new Ball(Vector2(50, 150), 20, cYellow); | |
57 | ||
3980ceb3 | 58 | ball->applyImpulse(Vector2(0.25,-0.05)), |
f72f4a59 PG |
59 | Balls.push(ball); |
60 | manager::add(ball); | |
61 | ||
62 | ball = new Ball(Vector2(100, 150), 20, cMagenta); | |
63 | ||
3980ceb3 | 64 | ball->applyImpulse(Vector2(-0.15,-0.05)), |
f72f4a59 PG |
65 | Balls.push(ball); |
66 | manager::add(ball); | |
67 | ||
68 | ball = new Ball(Vector2(150, 150), 20, cCyan); | |
69 | ||
3980ceb3 | 70 | ball->applyImpulse(Vector2(-0.15,0.05)), |
f72f4a59 PG |
71 | Balls.push(ball); |
72 | manager::add(ball); | |
054d658f PG |
73 | } |
74 | void creator::clean() | |
75 | { | |
f72f4a59 | 76 | removeAllBalls(); |
054d658f PG |
77 | } |
78 | ||
617dcc71 PG |
79 | /// ***** Public Methods ***** |
80 | ||
054d658f PG |
81 | void creator::addBall() |
82 | { | |
617dcc71 | 83 | //TODO |
054d658f PG |
84 | } |
85 | void creator::removeBall() | |
86 | { | |
617dcc71 | 87 | //TODO |
054d658f PG |
88 | } |
89 | void creator::removeAllBalls() | |
90 | { | |
f72f4a59 PG |
91 | while(! Balls.empty() ) |
92 | { | |
93 | Ball* ball = Balls.front(); | |
94 | Balls.pop(); | |
95 | manager::remove(ball); | |
054d658f | 96 | |
f72f4a59 PG |
97 | delete ball; |
98 | } | |
054d658f | 99 | } |