simple add balls implemented
[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     addBall(Vector2(50, 50), 20, cWhite);
36     addBall(Vector2(150, 50), 20, cGrey);
37     addBall(Vector2(50, 100), 20, cRed);
38     addBall(Vector2(100, 100), 20, cGreen);
39     addBall(Vector2(150, 100), 20, cBlue);
40     addBall(Vector2(50, 150), 20, cYellow);
41     addBall(Vector2(100, 150), 20, cMagenta);
42     addBall(Vector2(150, 150), 20, cCyan);
43 }
44 void creator::clean()
45 {
46     removeAllBalls();
47 }
48
49 /// ***** Public Methods *****
50
51 void creator::addBall(const Vector2& pos, float radius, const float* color)
52 {
53     Ball* ball = new Ball(pos, radius, color);
54
55     Balls.push(ball);
56     manager::add(ball);
57 }
58 void creator::removeBall()
59 {
60     Ball* ball = Balls.front();
61
62     Balls.pop();
63
64     delete ball;
65 }
66 void creator::removeAllBalls()
67 {
68     while(! Balls.empty() )
69     {
70         Ball* ball = Balls.front();
71         Balls.pop();
72         manager::remove(ball);
73
74         delete ball;
75     }
76 }