From: Patrik Gornicz Date: Sat, 19 Jul 2008 22:25:10 +0000 (-0400) Subject: added more colors and balls X-Git-Tag: physics-premerge~185 X-Git-Url: http://gitweb.pgornicz.com/gitweb.cgi?a=commitdiff_plain;h=f72f4a59026b8daa160908170f366c843aca5bb9;p=libbear.git added more colors and balls --- diff --git a/src/Makefile b/src/Makefile index fc76ec0..4ae7179 100644 --- a/src/Makefile +++ b/src/Makefile @@ -116,7 +116,7 @@ run: all .PHONY: val val: all - valgrind ${TARGET} + valgrind --leak-check=full ${TARGET} .PHONY: prof prof: all 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; + } } diff --git a/src/entityManager.cpp b/src/entityManager.cpp index 000fd4b..f707061 100644 --- a/src/entityManager.cpp +++ b/src/entityManager.cpp @@ -1,5 +1,4 @@ #include -using std::set; #include @@ -15,13 +14,13 @@ void updateParticles(float); void updatePhysics(float); /// ***** Private Variables ***** -typedef set setPart; +typedef std::set setPart; setPart particles_To_Add; setPart active_Particles; setPart particles_To_Remove; bool clearParticles; -typedef set setPhys; +typedef std::set setPhys; setPhys physics_To_Add; setPhys active_Physics; setPhys physics_To_Remove; diff --git a/src/graphics/colors.h b/src/graphics/colors.h index e502735..03e76ea 100644 --- a/src/graphics/colors.h +++ b/src/graphics/colors.h @@ -1,5 +1,12 @@ +static float const cWhite[] = {1.0, 1.0, 1.0}; +static float const cBlack[] = {0.0, 0.0, 0.0}; +static float const cGrey[] = {0.5, 0.5, 0.5}; + static float const cRed[] = {1.0, 0.0, 0.0}; static float const cGreen[] = {0.0, 1.0, 0.0}; static float const cBlue[] = {0.0, 0.0, 1.0}; + static float const cYellow[] = {1.0, 1.0, 0.0}; +static float const cMagenta[] = {1.0, 0.0, 1.0}; +static float const cCyan[] = {0.0, 1.0, 1.0};