From: Patrik Gornicz Date: Sat, 19 Jul 2008 21:40:46 +0000 (-0400) Subject: now draws a ball, fixed top of states bug X-Git-Tag: physics-premerge~187 X-Git-Url: http://gitweb.pgornicz.com/gitweb.cgi?a=commitdiff_plain;h=a483ed7507597d41a784028284a85083c9647045;p=libbear.git now draws a ball, fixed top of states bug --- diff --git a/src/GameStates/Running.cpp b/src/GameStates/Running.cpp index a09f912..b1d73d1 100644 --- a/src/GameStates/Running.cpp +++ b/src/GameStates/Running.cpp @@ -1,4 +1,5 @@ #include "Running.h" + #include "../entityManager.h" /// ***** Constructors/Destructors ***** diff --git a/src/entityCreator.cpp b/src/entityCreator.cpp index 6ed785d..f72cda3 100644 --- a/src/entityCreator.cpp +++ b/src/entityCreator.cpp @@ -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() diff --git a/src/entityManager.cpp b/src/entityManager.cpp index 815571b..000fd4b 100644 --- a/src/entityManager.cpp +++ b/src/entityManager.cpp @@ -4,6 +4,8 @@ using std::set; #include #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 ***** diff --git a/src/game.cpp b/src/game.cpp index 32a9e0b..ebf2ba7 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1,9 +1,9 @@ +#include "game.h" +#include "debug.h" + #include 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); diff --git a/src/main.cpp b/src/main.cpp index 5053640..98565a6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -70,9 +70,6 @@ void init() gameInit(); - // TODO - // add a game state - #ifdef DEBUGGING cout << "Initialization Complete" << endl; #endif