From: Patrik Gornicz Date: Thu, 21 Aug 2008 22:16:01 +0000 (-0400) Subject: simple add balls implemented X-Git-Tag: v0.06~2 X-Git-Url: http://gitweb.pgornicz.com/gitweb.cgi?a=commitdiff_plain;ds=sidebyside;h=88e62c4ff5f422b930c38ab643121e5f8607d889;p=physics.git simple add balls implemented --- diff --git a/src/Makefile b/src/Makefile index b04d5cd..b45814a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -6,11 +6,10 @@ LIBS := ${LIBSDL} ${LIBGL} OPTFLAGS := -O2 DBGFLAGS := -ggdb PRFFLAGS := ${DBGFLAGS} -pg -VALFLAGS := --leak-check=full - -#CXX := g++ CXXFLAGS := -Wall -pedantic -ansi ${DBGFLAGS} +VALFLAGS := --leak-check=full + TARGET := ../run_physics SRCS := # simply to keep every line below the same diff --git a/src/entityCreator.cpp b/src/entityCreator.cpp index d24083f..eddfb3d 100644 --- a/src/entityCreator.cpp +++ b/src/entityCreator.cpp @@ -32,61 +32,14 @@ queBall Balls; void creator::init() { - Ball* ball; - - ball = new Ball(Vector2(50, 50), 20, cWhite); - - ball->applyImpulse(Vector2(0.25,0.05)), - Balls.push(ball); - manager::add(ball); - - ball = new Ball(Vector2(100, 50), 20, cBlack); - - ball->applyImpulse(Vector2(-0.15,-0.05)), - Balls.push(ball); - manager::add(ball); - - ball = new Ball(Vector2(150, 50), 20, cGrey); - - ball->applyImpulse(Vector2(0.25,0.15)), - Balls.push(ball); - manager::add(ball); - - ball = new Ball(Vector2(50, 100), 20, cRed); - - ball->applyImpulse(Vector2(0.35,-0.15)), - Balls.push(ball); - manager::add(ball); - - ball = new Ball(Vector2(100, 100), 20, cGreen); - - ball->applyImpulse(Vector2(-0.15,0.55)), - Balls.push(ball); - manager::add(ball); - - ball = new Ball(Vector2(150, 100), 20, cBlue); - - ball->applyImpulse(Vector2(0.25,0.15)), - Balls.push(ball); - manager::add(ball); - - ball = new Ball(Vector2(50, 150), 20, cYellow); - - ball->applyImpulse(Vector2(0.25,-0.05)), - Balls.push(ball); - manager::add(ball); - - ball = new Ball(Vector2(100, 150), 20, cMagenta); - - ball->applyImpulse(Vector2(-0.15,-0.05)), - Balls.push(ball); - manager::add(ball); - - ball = new Ball(Vector2(150, 150), 20, cCyan); - - ball->applyImpulse(Vector2(-0.15,0.05)), - Balls.push(ball); - manager::add(ball); + addBall(Vector2(50, 50), 20, cWhite); + addBall(Vector2(150, 50), 20, cGrey); + addBall(Vector2(50, 100), 20, cRed); + addBall(Vector2(100, 100), 20, cGreen); + addBall(Vector2(150, 100), 20, cBlue); + addBall(Vector2(50, 150), 20, cYellow); + addBall(Vector2(100, 150), 20, cMagenta); + addBall(Vector2(150, 150), 20, cCyan); } void creator::clean() { @@ -95,13 +48,20 @@ void creator::clean() /// ***** Public Methods ***** -void creator::addBall() +void creator::addBall(const Vector2& pos, float radius, const float* color) { - //TODO + Ball* ball = new Ball(pos, radius, color); + + Balls.push(ball); + manager::add(ball); } void creator::removeBall() { - //TODO + Ball* ball = Balls.front(); + + Balls.pop(); + + delete ball; } void creator::removeAllBalls() { diff --git a/src/entityCreator.h b/src/entityCreator.h index 259ac24..6987c34 100644 --- a/src/entityCreator.h +++ b/src/entityCreator.h @@ -18,6 +18,7 @@ #ifndef ENTITYCREATOR_H #define ENTITYCREATOR_H +#include "Vector2.h" /// ***** Header Methods ***** namespace creator @@ -25,8 +26,10 @@ namespace creator void init(); void clean(); - void addBall(); + void addBall(const Vector2& pos, float radius, const float* color); void removeBall(); void removeAllBalls(); + + void input(); } #endif // ENTITYCREATOR_H