simple add balls implemented
authorPatrik Gornicz <Gornicz.P@gmail.com>
Thu, 21 Aug 2008 22:16:01 +0000 (18:16 -0400)
committerPatrik Gornicz <Gornicz.P@gmail.com>
Thu, 21 Aug 2008 22:16:01 +0000 (18:16 -0400)
src/Makefile
src/entityCreator.cpp
src/entityCreator.h

index b04d5cd..b45814a 100644 (file)
@@ -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
index d24083f..eddfb3d 100644 (file)
@@ -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()
 {
index 259ac24..6987c34 100644 (file)
@@ -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