X-Git-Url: http://gitweb.pgornicz.com/gitweb.cgi?p=physics.git;a=blobdiff_plain;f=src%2FentityCreator.cpp;h=aa5db0ef5dbe3e7cb44b7b5ea6900fc106c1cdb1;hp=f72cda39da676ecbf128583e34671d8c10117294;hb=f72f4a59026b8daa160908170f366c843aca5bb9;hpb=63ae369aa5699bbeb3613586ac446c2a5c1868e2 diff --git a/src/entityCreator.cpp b/src/entityCreator.cpp index f72cda3..aa5db0e 100644 --- a/src/entityCreator.cpp +++ b/src/entityCreator.cpp @@ -1,27 +1,71 @@ #include "entityCreator.h" +#include + #include "entityManager.h" #include "Entities/Ball.h" #include "graphics/colors.h" /// ***** Private Method Headers ***** -Ball* ball1; +typedef std::queue queBall; +queBall Balls; /// ***** Private Variables ***** /// ***** Public Methods ***** void creator::init() { - Vector2 pos(400, 400); - ball1 = new Ball(pos, 20, cBlue); + Ball* ball; + + // needs to be first for the overlap + ball = new Ball(Vector2(50, 50), 20, cWhite); + + Balls.push(ball); + manager::add(ball); + + ball = new Ball(Vector2(100, 50), 20, cBlack); + + Balls.push(ball); + manager::add(ball); + + ball = new Ball(Vector2(150, 50), 20, cGrey); + + Balls.push(ball); + manager::add(ball); + + ball = new Ball(Vector2(50, 100), 20, cRed); + + Balls.push(ball); + manager::add(ball); + + ball = new Ball(Vector2(100, 100), 20, cGreen); - manager::add(ball1); + Balls.push(ball); + manager::add(ball); + + ball = new Ball(Vector2(150, 100), 20, cBlue); + + Balls.push(ball); + manager::add(ball); + + ball = new Ball(Vector2(50, 150), 20, cYellow); + + Balls.push(ball); + manager::add(ball); + + ball = new Ball(Vector2(100, 150), 20, cMagenta); + + Balls.push(ball); + manager::add(ball); + + ball = new Ball(Vector2(150, 150), 20, cCyan); + + Balls.push(ball); + manager::add(ball); } void creator::clean() { - manager::remove(ball1); - - delete ball1; + removeAllBalls(); } void creator::addBall() @@ -34,5 +78,12 @@ void creator::removeBall() } void creator::removeAllBalls() { + while(! Balls.empty() ) + { + Ball* ball = Balls.front(); + Balls.pop(); + manager::remove(ball); + delete ball; + } }