added GPL copyrights
[physics.git] / src / entityCreator.cpp
1 /*
2  *  Copyright (C) 2008 Patrik Gornicz, Gornicz_P (at) hotmail (dot) com.
3  *
4  *  This program is free software: you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation, either version 3 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 #include "entityCreator.h"
19
20 #include <queue>
21
22 #include "entityManager.h"
23 #include "Entities/Ball.h"
24 #include "graphics/colors.h"
25
26 /// ***** Private Variables *****
27
28 typedef std::queue<Ball*> queBall;
29 queBall Balls;
30
31 /// ***** Initializers/Cleaners *****
32
33 void creator::init()
34 {
35     Ball* ball;
36
37     ball = new Ball(Vector2(50, 50), 20, cWhite);
38
39     ball->applyImpulse(Vector2(0.25,0.05)),
40     Balls.push(ball);
41     manager::add(ball);
42
43     ball = new Ball(Vector2(100, 50), 20, cBlack);
44
45     ball->applyImpulse(Vector2(-0.15,-0.05)),
46     Balls.push(ball);
47     manager::add(ball);
48
49     ball = new Ball(Vector2(150, 50), 20, cGrey);
50
51     ball->applyImpulse(Vector2(0.25,0.15)),
52     Balls.push(ball);
53     manager::add(ball);
54
55     ball = new Ball(Vector2(50, 100), 20, cRed);
56
57     ball->applyImpulse(Vector2(0.35,-0.15)),
58     Balls.push(ball);
59     manager::add(ball);
60
61     ball = new Ball(Vector2(100, 100), 20, cGreen);
62
63     ball->applyImpulse(Vector2(-0.15,0.55)),
64     Balls.push(ball);
65     manager::add(ball);
66
67     ball = new Ball(Vector2(150, 100), 20, cBlue);
68
69     ball->applyImpulse(Vector2(0.25,0.15)),
70     Balls.push(ball);
71     manager::add(ball);
72
73     ball = new Ball(Vector2(50, 150), 20, cYellow);
74
75     ball->applyImpulse(Vector2(0.25,-0.05)),
76     Balls.push(ball);
77     manager::add(ball);
78
79     ball = new Ball(Vector2(100, 150), 20, cMagenta);
80
81     ball->applyImpulse(Vector2(-0.15,-0.05)),
82     Balls.push(ball);
83     manager::add(ball);
84
85     ball = new Ball(Vector2(150, 150), 20, cCyan);
86
87     ball->applyImpulse(Vector2(-0.15,0.05)),
88     Balls.push(ball);
89     manager::add(ball);
90 }
91 void creator::clean()
92 {
93     removeAllBalls();
94 }
95
96 /// ***** Public Methods *****
97
98 void creator::addBall()
99 {
100     //TODO
101 }
102 void creator::removeBall()
103 {
104     //TODO
105 }
106 void creator::removeAllBalls()
107 {
108     while(! Balls.empty() )
109     {
110         Ball* ball = Balls.front();
111         Balls.pop();
112         manager::remove(ball);
113
114         delete ball;
115     }
116 }