added GPL copyrights
[physics.git] / src / entityCreator.cpp
CommitLineData
e68f847b
PG
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
054d658f
PG
18#include "entityCreator.h"
19
f72f4a59
PG
20#include <queue>
21
a483ed75
PG
22#include "entityManager.h"
23#include "Entities/Ball.h"
24#include "graphics/colors.h"
25
617dcc71
PG
26/// ***** Private Variables *****
27
f72f4a59
PG
28typedef std::queue<Ball*> queBall;
29queBall Balls;
a483ed75 30
617dcc71 31/// ***** Initializers/Cleaners *****
a483ed75 32
054d658f
PG
33void creator::init()
34{
f72f4a59
PG
35 Ball* ball;
36
f72f4a59
PG
37 ball = new Ball(Vector2(50, 50), 20, cWhite);
38
3980ceb3 39 ball->applyImpulse(Vector2(0.25,0.05)),
f72f4a59
PG
40 Balls.push(ball);
41 manager::add(ball);
42
43 ball = new Ball(Vector2(100, 50), 20, cBlack);
44
3980ceb3 45 ball->applyImpulse(Vector2(-0.15,-0.05)),
f72f4a59
PG
46 Balls.push(ball);
47 manager::add(ball);
48
49 ball = new Ball(Vector2(150, 50), 20, cGrey);
50
3980ceb3 51 ball->applyImpulse(Vector2(0.25,0.15)),
f72f4a59
PG
52 Balls.push(ball);
53 manager::add(ball);
54
55 ball = new Ball(Vector2(50, 100), 20, cRed);
56
3980ceb3 57 ball->applyImpulse(Vector2(0.35,-0.15)),
f72f4a59
PG
58 Balls.push(ball);
59 manager::add(ball);
60
61 ball = new Ball(Vector2(100, 100), 20, cGreen);
054d658f 62
094a13b8 63 ball->applyImpulse(Vector2(-0.15,0.55)),
f72f4a59
PG
64 Balls.push(ball);
65 manager::add(ball);
66
67 ball = new Ball(Vector2(150, 100), 20, cBlue);
68
3980ceb3 69 ball->applyImpulse(Vector2(0.25,0.15)),
f72f4a59
PG
70 Balls.push(ball);
71 manager::add(ball);
72
73 ball = new Ball(Vector2(50, 150), 20, cYellow);
74
3980ceb3 75 ball->applyImpulse(Vector2(0.25,-0.05)),
f72f4a59
PG
76 Balls.push(ball);
77 manager::add(ball);
78
79 ball = new Ball(Vector2(100, 150), 20, cMagenta);
80
3980ceb3 81 ball->applyImpulse(Vector2(-0.15,-0.05)),
f72f4a59
PG
82 Balls.push(ball);
83 manager::add(ball);
84
85 ball = new Ball(Vector2(150, 150), 20, cCyan);
86
3980ceb3 87 ball->applyImpulse(Vector2(-0.15,0.05)),
f72f4a59
PG
88 Balls.push(ball);
89 manager::add(ball);
054d658f
PG
90}
91void creator::clean()
92{
f72f4a59 93 removeAllBalls();
054d658f
PG
94}
95
617dcc71
PG
96/// ***** Public Methods *****
97
054d658f
PG
98void creator::addBall()
99{
617dcc71 100 //TODO
054d658f
PG
101}
102void creator::removeBall()
103{
617dcc71 104 //TODO
054d658f
PG
105}
106void creator::removeAllBalls()
107{
f72f4a59
PG
108 while(! Balls.empty() )
109 {
110 Ball* ball = Balls.front();
111 Balls.pop();
112 manager::remove(ball);
054d658f 113
f72f4a59
PG
114 delete ball;
115 }
054d658f 116}