now draws a ball, fixed top of states bug
authorPatrik Gornicz <Gornicz.P@gmail.com>
Sat, 19 Jul 2008 21:40:46 +0000 (17:40 -0400)
committerPatrik Gornicz <Gornicz.P@gmail.com>
Sat, 19 Jul 2008 21:40:46 +0000 (17:40 -0400)
src/GameStates/Running.cpp
src/entityCreator.cpp
src/entityManager.cpp
src/game.cpp
src/main.cpp

index a09f912..b1d73d1 100644 (file)
@@ -1,4 +1,5 @@
 #include "Running.h"
+
 #include "../entityManager.h"
 
 /// ***** Constructors/Destructors *****
index 6ed785d..f72cda3 100644 (file)
@@ -1,12 +1,27 @@
 #include "entityCreator.h"
 
+#include "entityManager.h"
+#include "Entities/Ball.h"
+#include "graphics/colors.h"
+
+/// ***** Private Method Headers *****
+Ball* ball1;
+
+/// ***** Private Variables *****
+
+/// ***** Public Methods *****
 void creator::init()
 {
+    Vector2 pos(400, 400);
+    ball1 = new Ball(pos, 20, cBlue);
 
+    manager::add(ball1);
 }
 void creator::clean()
 {
+    manager::remove(ball1);
 
+    delete ball1;
 }
 
 void creator::addBall()
index 815571b..000fd4b 100644 (file)
@@ -4,6 +4,8 @@ using std::set;
 #include <iostream>
 
 #include "entityManager.h"
+#include "debug.h"
+
 #include "Entities/Entity.h"
 #include "Entities/Particle.h"
 #include "Entities/PhysicsEntity.h"
@@ -113,6 +115,7 @@ void manager::draw()
     {
         (*it)->draw();
     }
+
 }
 
 /// ***** Private Methods *****
index 32a9e0b..ebf2ba7 100644 (file)
@@ -1,9 +1,9 @@
+#include "game.h"
+#include "debug.h"
+
 #include <vector>
 using std::vector;
 
-#include "game.h"
-
-#include "debug.h"
 #include "entityCreator.h"
 
 #include "GameStates/GameState.h"
@@ -31,9 +31,10 @@ void gameInit()
     creating_Polygon = new CreatingPolygon();
 
     // create starting entities
-
     creator::init();
 
+    active_States.push_back(running);
+
 #ifdef DEBUGGING
     cout << "World Created" << endl;
 #endif
@@ -50,27 +51,26 @@ void gameClean()
 
 void gameInput()
 {
-    int size = active_States.size();
+    int last = active_States.size() -1;
     for( int i = 0;
-         i < size;
+         i <= last;
          i++ )
     {
-        if( i-1 == size )
+        if( i == last )
             active_States[i]->handleInput(true);
         else
             active_States[i]->handleInput(false);
     }
-
 }
 
 void gameUpdate(float time_step)
 {
-    int size = active_States.size();
+    int last = active_States.size() -1;
     for( int i = 0;
-         i < size;
+         i <= last;
          i++ )
     {
-        if( i-1 == size )
+        if( i == last )
             active_States[i]->update(time_step, true);
         else
             active_States[i]->update(time_step, false);
@@ -79,12 +79,12 @@ void gameUpdate(float time_step)
 
 void gameDraw()
 {
-    int size = active_States.size();
+    int last = active_States.size() -1;
     for( int i = 0;
-         i < size;
+         i <= last;
          i++ )
     {
-        if( i-1 == size )
+        if( i == last )
             active_States[i]->draw(true);
         else
             active_States[i]->draw(false);
index 5053640..98565a6 100644 (file)
@@ -70,9 +70,6 @@ void init()
 
     gameInit();
 
-    // TODO
-    // add a game state
-
 #ifdef DEBUGGING
     cout << "Initialization Complete" << endl;
 #endif