From 617dcc71d9a71663f63fb56ffac2505b45bf91b9 Mon Sep 17 00:00:00 2001 From: Patrik Gornicz Date: Sat, 2 Aug 2008 16:58:52 -0400 Subject: [PATCH] massive cleaning of file section headers --- src/Effects/Effect.cpp | 5 +++ src/Effects/Effect.h | 4 +- src/Effects/Gravity.cpp | 5 +++ src/Effects/Gravity.h | 4 +- src/Effects/Screen.cpp | 6 ++- src/Effects/Screen.h | 4 +- src/Entities/Ball.cpp | 6 ++- src/Entities/Ball.h | 2 + src/Entities/Entity.cpp | 23 ++++++----- src/Entities/Entity.h | 2 + src/Entities/Line.cpp | 7 +++- src/Entities/Line.h | 5 +-- src/Entities/Particle.cpp | 7 +++- src/Entities/Particle.h | 3 ++ src/Entities/PhysicsEntity.cpp | 10 ++++- src/Entities/PhysicsEntity.h | 2 + src/Entities/Point.cpp | 7 +++- src/Entities/Point.h | 5 +-- src/Entities/Polygon.cpp | 11 +++-- src/Entities/Polygon.h | 4 +- src/Entities/WindParticle.cpp | 7 +++- src/Entities/WindParticle.h | 2 + src/GameStates/CreatingPolygon.cpp | 3 ++ src/GameStates/CreatingPolygon.h | 2 + src/GameStates/GameState.cpp | 2 + src/GameStates/GameState.h | 2 + src/GameStates/Paused.cpp | 3 ++ src/GameStates/Paused.h | 2 + src/GameStates/Running.cpp | 3 ++ src/GameStates/Running.h | 2 + src/Vector2.cpp | 85 +++++++++++++++++++++++--------------- src/Vector2.h | 7 +++- src/codingstyle.txt | 18 ++++---- src/debug.h | 10 +++-- src/effectManager.cpp | 5 ++- src/effectManager.h | 1 + src/entityCreator.cpp | 12 +++--- src/entityCreator.h | 1 - src/entityManager.cpp | 16 +++---- src/entityManager.h | 1 - src/graphics/colors.h | 2 + src/graphics/graphics.cpp | 12 +++--- src/graphics/graphics.h | 3 +- src/handleSignal.cpp | 2 +- src/init.h | 13 ------ src/input/inputManager.cpp | 12 +++++- src/input/inputManager.h | 4 ++ src/main.cpp | 38 +++++++++-------- src/mathw.cpp | 7 +--- src/mathw.h | 4 ++ 50 files changed, 261 insertions(+), 142 deletions(-) delete mode 100644 src/init.h diff --git a/src/Effects/Effect.cpp b/src/Effects/Effect.cpp index f6bf921..a050c47 100644 --- a/src/Effects/Effect.cpp +++ b/src/Effects/Effect.cpp @@ -1,5 +1,8 @@ #include "Effect.h" + +/// ***** Constructors/Destructors ***** + Effect::Effect() { @@ -10,6 +13,8 @@ Effect::~Effect() } +/// ***** Public Class Methods ***** + Vector2 Effect::positionDelta(const PhysicsEntity*, float) const { return Vector2(0,0); diff --git a/src/Effects/Effect.h b/src/Effects/Effect.h index 5d0f1f9..bba1438 100644 --- a/src/Effects/Effect.h +++ b/src/Effects/Effect.h @@ -3,10 +3,12 @@ #include "../Vector2.h" -//#include "../Entities/PhysicsEntity.h" + +// Mutual headers ... class PhysicsEntity; /// ***** Header Class ***** + class Effect { protected: diff --git a/src/Effects/Gravity.cpp b/src/Effects/Gravity.cpp index 9d0ac65..d2c73cb 100644 --- a/src/Effects/Gravity.cpp +++ b/src/Effects/Gravity.cpp @@ -1,5 +1,8 @@ #include "Gravity.h" + +/// ***** Constructors/Destructors ***** + Gravity::Gravity() { @@ -9,6 +12,8 @@ Gravity::~Gravity() } +/// ***** Public Class Methods ***** + Vector2 Gravity::forceDelta(const PhysicsEntity*, float) const { return Vector2(0, 0.001); diff --git a/src/Effects/Gravity.h b/src/Effects/Gravity.h index 1675a6c..64ab3e5 100644 --- a/src/Effects/Gravity.h +++ b/src/Effects/Gravity.h @@ -1,10 +1,12 @@ #ifndef GRAVITY_H #define GRAVITY_H -#include "../Vector2.h" #include "Effect.h" +#include "../Vector2.h" + /// ***** Header Class ***** + class Gravity: public Effect { public: diff --git a/src/Effects/Screen.cpp b/src/Effects/Screen.cpp index 9d81238..e280e1b 100644 --- a/src/Effects/Screen.cpp +++ b/src/Effects/Screen.cpp @@ -1,9 +1,11 @@ #include "Screen.h" -#include "../debug.h" #include "../Entities/PhysicsEntity.h" #include "../Entities/Ball.h" + +/// ***** Constructors/Destructors ***** + Screen::Screen() { @@ -13,6 +15,8 @@ Screen::~Screen() } +/// ***** Public Class Methods ***** + Vector2 Screen::velocityDelta(const PhysicsEntity* e, float time_step) const { const Vector2& pos = e->positionRaw(); diff --git a/src/Effects/Screen.h b/src/Effects/Screen.h index 2e32e95..3716980 100644 --- a/src/Effects/Screen.h +++ b/src/Effects/Screen.h @@ -1,10 +1,12 @@ #ifndef SCREEN_H #define SCREEN_H -#include "../Vector2.h" #include "Effect.h" +#include "../Vector2.h" + /// ***** Header Class ***** + class Screen: public Effect { public: diff --git a/src/Entities/Ball.cpp b/src/Entities/Ball.cpp index 23180f0..5bee89a 100644 --- a/src/Entities/Ball.cpp +++ b/src/Entities/Ball.cpp @@ -4,7 +4,9 @@ #include "../Vector2.h" #include "../graphics/graphics.h" -/// ***** Public Class Methods ***** + +/// ***** Constructors/Destructors ***** + Ball::Ball(const Vector2& pos, float radius, const float* color) : PhysicsEntity(pos), radius(radius), color(color) { @@ -15,6 +17,8 @@ Ball::~Ball() } +/// ***** Public Class Methods ***** + void Ball::draw() const { glDrawCircle(radius, position, color); diff --git a/src/Entities/Ball.h b/src/Entities/Ball.h index 5dcffaa..40f2e2a 100644 --- a/src/Entities/Ball.h +++ b/src/Entities/Ball.h @@ -4,7 +4,9 @@ #include "PhysicsEntity.h" #include "../Vector2.h" + /// ***** Header Class ***** + class Ball: public PhysicsEntity { public: diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 5365bcc..e3b3869 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1,7 +1,19 @@ #include "Entity.h" + #include "../Vector2.h" -#include + +/// ***** Constructors/Destructors ***** + +Entity::Entity(const Vector2& pos) + : position(pos), velocity(0,0) +{ + +} +Entity::~Entity() +{ + +} /// ***** Public Class Methods ***** @@ -14,12 +26,3 @@ const Vector2& Entity::velocityRaw() const return velocity; } -Entity::Entity(const Vector2& pos) - : position(pos), velocity(0,0) -{ - -} -Entity::~Entity() -{ - -} diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index b5b268d..c40d44c 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -3,7 +3,9 @@ #include "../Vector2.h" + /// ***** Header Class ***** + class Entity { protected: diff --git a/src/Entities/Line.cpp b/src/Entities/Line.cpp index 4814eff..d28947e 100644 --- a/src/Entities/Line.cpp +++ b/src/Entities/Line.cpp @@ -1,7 +1,10 @@ #include "Line.h" + #include "../Vector2.h" -/// ***** Public Class Methods ***** + +/// ***** Constructors/Destructors ***** + Line::Line(const Vector2& org, const Vector2& dest, bool canDie) : Particle(org, canDie), dest(dest) { @@ -17,6 +20,8 @@ Line::~Line() } +/// ***** Public Class Methods ***** + void Line::draw() { // TODO diff --git a/src/Entities/Line.h b/src/Entities/Line.h index 5798655..02169d6 100644 --- a/src/Entities/Line.h +++ b/src/Entities/Line.h @@ -4,12 +4,9 @@ #include "Particle.h" #include "../Vector2.h" -/// NOTE to SELF -// a Particle should be drawn for at least the next frame -// ie. creating a particle using ParticleE(Vector2), -// should draw the particle once THEN kill it /// ***** Header Class ***** + class Line: public Particle { public: diff --git a/src/Entities/Particle.cpp b/src/Entities/Particle.cpp index da9a6d1..6aae3ed 100644 --- a/src/Entities/Particle.cpp +++ b/src/Entities/Particle.cpp @@ -1,7 +1,10 @@ #include "Particle.h" + #include "../Vector2.h" -/// ***** Public Class Methods ***** + +/// ***** Constructors/Destructors ***** + Particle::Particle(const Vector2& pos, bool canDie) : Entity(pos), canDie(canDie) { @@ -17,6 +20,8 @@ Particle::~Particle() } +/// ***** Public Class Methods ***** + void Particle::update(float time_step) { if(isDead) diff --git a/src/Entities/Particle.h b/src/Entities/Particle.h index 76c7187..6843366 100644 --- a/src/Entities/Particle.h +++ b/src/Entities/Particle.h @@ -4,12 +4,15 @@ #include "Entity.h" #include "../Vector2.h" + /// NOTE to SELF // a Particle should be drawn for at least the next frame // ie. creating a particle using ParticleE(Vector2), // should draw the particle once THEN kill it + /// ***** Header Class ***** + class Particle: public Entity { protected: diff --git a/src/Entities/PhysicsEntity.cpp b/src/Entities/PhysicsEntity.cpp index fba6a89..30e689e 100644 --- a/src/Entities/PhysicsEntity.cpp +++ b/src/Entities/PhysicsEntity.cpp @@ -1,18 +1,24 @@ #include "PhysicsEntity.h" #include "../debug.h" -#include "../Vector2.h" #include "../effectManager.h" +#include "../Vector2.h" + + +/// ***** Constructors/Destructors ***** -/// ***** Public Class Methods ***** PhysicsEntity::PhysicsEntity(const Vector2& pos) : Entity(pos), force(0,0), mass(1), CoR(1) { + } PhysicsEntity::~PhysicsEntity() { + } +/// ***** Public Class Methods ***** + void PhysicsEntity::update(float time_step) { position = positionAt(time_step); diff --git a/src/Entities/PhysicsEntity.h b/src/Entities/PhysicsEntity.h index 85c0558..990c2c7 100644 --- a/src/Entities/PhysicsEntity.h +++ b/src/Entities/PhysicsEntity.h @@ -4,7 +4,9 @@ #include "Entity.h" #include "../Vector2.h" + /// ***** Header Class ***** + class PhysicsEntity: public Entity { protected: diff --git a/src/Entities/Point.cpp b/src/Entities/Point.cpp index 63334ea..a443cfa 100644 --- a/src/Entities/Point.cpp +++ b/src/Entities/Point.cpp @@ -1,7 +1,10 @@ #include "Point.h" + #include "../Vector2.h" -/// ***** Public Class Methods ***** + +/// ***** Constructors/Destructors ***** + Point::Point(const Vector2& org, bool canDie) : Particle(org, canDie), radius(2) { @@ -17,6 +20,8 @@ Point::~Point() } +/// ***** Public Class Methods ***** + void Point::draw() { // TODO diff --git a/src/Entities/Point.h b/src/Entities/Point.h index 459729c..27812b2 100644 --- a/src/Entities/Point.h +++ b/src/Entities/Point.h @@ -4,12 +4,9 @@ #include "Particle.h" #include "../Vector2.h" -/// NOTE to SELF -// a Particle should be drawn for at least the next frame -// ie. creating a particle using ParticleE(Vector2), -// should draw the particle once THEN kill it /// ***** Header Class ***** + class Point: public Particle { public: diff --git a/src/Entities/Polygon.cpp b/src/Entities/Polygon.cpp index dc25174..085c6e2 100644 --- a/src/Entities/Polygon.cpp +++ b/src/Entities/Polygon.cpp @@ -1,24 +1,29 @@ #include "Polygon.h" + #include "../Vector2.h" -/// ***** Public Class Methods ***** + +/// ***** Constructors/Destructors ***** + Polygon::Polygon(const Vector2& pos, vector points) : PhysicsEntity(pos), points(points) { - CreateBindingBox(); + createBindingBox(); } Polygon::~Polygon() { } +/// ***** Public Class Methods ***** + void Polygon::draw() const { // TODO } /// ***** Private Class Methods ***** -void Polygon::CreateBindingBox() +void Polygon::createBindingBox() { // TODO } diff --git a/src/Entities/Polygon.h b/src/Entities/Polygon.h index c457803..222e4cd 100644 --- a/src/Entities/Polygon.h +++ b/src/Entities/Polygon.h @@ -7,7 +7,9 @@ #include using std::vector; + /// ***** Header Class ***** + class Polygon: public PhysicsEntity { public: @@ -24,7 +26,7 @@ class Polygon: public PhysicsEntity // color; private: - void CreateBindingBox(); + void createBindingBox(); }; #endif // POLYGON_H diff --git a/src/Entities/WindParticle.cpp b/src/Entities/WindParticle.cpp index 91b0dfa..867f271 100644 --- a/src/Entities/WindParticle.cpp +++ b/src/Entities/WindParticle.cpp @@ -1,7 +1,10 @@ #include "WindParticle.h" + #include "../Vector2.h" -/// ***** Public Class Methods ***** + +/// ***** Constructors/Destructors ***** + WindParticle::WindParticle(const Vector2& org, float life_time) : Point(org, life_time) { @@ -12,6 +15,8 @@ WindParticle::~WindParticle() } +/// ***** Public Class Methods ***** + void WindParticle::update(float time_step) { Point::update(time_step); diff --git a/src/Entities/WindParticle.h b/src/Entities/WindParticle.h index c39bc40..43b8794 100644 --- a/src/Entities/WindParticle.h +++ b/src/Entities/WindParticle.h @@ -4,7 +4,9 @@ #include "Point.h" #include "../Vector2.h" + /// ***** Header Class ***** + class WindParticle: public Point { public: diff --git a/src/GameStates/CreatingPolygon.cpp b/src/GameStates/CreatingPolygon.cpp index fec57dd..d0208da 100644 --- a/src/GameStates/CreatingPolygon.cpp +++ b/src/GameStates/CreatingPolygon.cpp @@ -1,6 +1,8 @@ #include "CreatingPolygon.h" + /// ***** Constructors/Destructors ***** + CreatingPolygon::CreatingPolygon() { @@ -11,6 +13,7 @@ CreatingPolygon::~CreatingPolygon() } /// ***** Public Class Methods ***** + void CreatingPolygon::handleInput(bool on_top) const { // TODO diff --git a/src/GameStates/CreatingPolygon.h b/src/GameStates/CreatingPolygon.h index f27f721..b4438af 100644 --- a/src/GameStates/CreatingPolygon.h +++ b/src/GameStates/CreatingPolygon.h @@ -3,7 +3,9 @@ #include "GameState.h" + /// ***** Header Class ***** + class CreatingPolygon : public GameState { public: diff --git a/src/GameStates/GameState.cpp b/src/GameStates/GameState.cpp index 5bf1226..ed2017b 100644 --- a/src/GameStates/GameState.cpp +++ b/src/GameStates/GameState.cpp @@ -1,6 +1,8 @@ #include "GameState.h" + /// ***** Constructors/Destructors ***** + GameState::GameState() { diff --git a/src/GameStates/GameState.h b/src/GameStates/GameState.h index 13e0d78..32ca731 100644 --- a/src/GameStates/GameState.h +++ b/src/GameStates/GameState.h @@ -1,7 +1,9 @@ #ifndef GAMESTATE_H #define GAMESTATE_H + /// ***** Header Class ***** + class GameState { protected: diff --git a/src/GameStates/Paused.cpp b/src/GameStates/Paused.cpp index c3c2e2d..72a4c43 100644 --- a/src/GameStates/Paused.cpp +++ b/src/GameStates/Paused.cpp @@ -1,6 +1,8 @@ #include "Paused.h" + /// ***** Constructors/Destructors ***** + Paused::Paused() { @@ -11,6 +13,7 @@ Paused::~Paused() } /// ***** Public Class Methods ***** + void Paused::handleInput(bool on_top) const { // TODO diff --git a/src/GameStates/Paused.h b/src/GameStates/Paused.h index 536da72..47f3e62 100644 --- a/src/GameStates/Paused.h +++ b/src/GameStates/Paused.h @@ -3,7 +3,9 @@ #include "GameState.h" + /// ***** Header Class ***** + class Paused : public GameState { public: diff --git a/src/GameStates/Running.cpp b/src/GameStates/Running.cpp index b1d73d1..3355d0c 100644 --- a/src/GameStates/Running.cpp +++ b/src/GameStates/Running.cpp @@ -2,7 +2,9 @@ #include "../entityManager.h" + /// ***** Constructors/Destructors ***** + Running::Running() { manager::init(); @@ -13,6 +15,7 @@ Running::~Running() } /// ***** Public Class Methods ***** + void Running::handleInput(bool on_top) const { if( on_top ) diff --git a/src/GameStates/Running.h b/src/GameStates/Running.h index 259b216..f20a34d 100644 --- a/src/GameStates/Running.h +++ b/src/GameStates/Running.h @@ -3,7 +3,9 @@ #include "GameState.h" + /// ***** Header Class ***** + class Running : public GameState { public: diff --git a/src/Vector2.cpp b/src/Vector2.cpp index 8028aa3..4d4b85a 100644 --- a/src/Vector2.cpp +++ b/src/Vector2.cpp @@ -1,119 +1,136 @@ #include "Vector2.h" #include "mathw.h" +/// ***** Constructors/Destructors ***** + Vector2::Vector2() : x(0), y(0) { + } Vector2::Vector2(float x, float y) : x(x), y(y) { + } Vector2::Vector2(const Vector2& vec) : x(vec.x), y(vec.y) { + +} +Vector2::~Vector2() +{ + } +/// ***** Public Class Methods ***** + void Vector2::zero() { - x = 0; - y = 0; + x = 0; + y = 0; } void Vector2::unit() { - float len = length(); + float len = length(); - x /= len; - y /= len; + x /= len; + y /= len; } float Vector2::angle() const { - //return atan2A(y,x); - return 0; + //TODO + //return atan2A(y,x); + return 0; } float Vector2::length() const { - return sqrt(x*x + y*y); + return sqrt(x*x + y*y); } string Vector2::toString() const { - char* strX = new char[50]; // long just to be safe - char* strY = new char[50]; // long just to be safe - sprintf(strX, "%f", x); - sprintf(strY, "%f", y); + // long just to be safe + char* strX = new char[50]; + char* strY = new char[50]; + + sprintf(strX, "%f", x); + sprintf(strY, "%f", y); + + string val = (string)"Vector2 x: " + strX + ", y: " + strY; - string val = (string)"Vector2 x: " + strX + ", y: " + strY; - delete []strX; // deletes the memory allocated, not just what is used by sprintf - delete []strY; // deletes the memory allocated, not just what is used by sprintf + // deletes the allocated memory, not just what is used by sprintf + delete []strX; + delete []strY; - return val; + return val; } void Vector2::print() const { - printf("%s\n",toString().c_str()); + printf("%s\n",toString().c_str()); } Vector2 Vector2::add(const Vector2& vec) const { - return Vector2(x+vec.x, y+vec.y); + return Vector2(x+vec.x, y+vec.y); } Vector2 Vector2::subtract(const Vector2& vec) const { - return Vector2(x-vec.x, y-vec.y); + return Vector2(x-vec.x, y-vec.y); } Vector2 Vector2::multiply(float c) const { - return Vector2(x*c, y*c); + return Vector2(x*c, y*c); } Vector2 Vector2::divide(float c) const { - return Vector2(x/c, y/c); + return Vector2(x/c, y/c); } +/// ***** Public Methods ***** Vector2 operator+(const Vector2& vec1, const Vector2& vec2) { - return vec1.add(vec2); + return vec1.add(vec2); } Vector2 operator-(const Vector2& vec1, const Vector2& vec2) { - return vec1.subtract(vec2); + return vec1.subtract(vec2); } Vector2 operator*(float c, const Vector2& vec) { - return vec.multiply(c); + return vec.multiply(c); } Vector2 operator*(const Vector2& vec, float c) { - return vec.multiply(c); + return vec.multiply(c); } Vector2 operator/(const Vector2& vec, float c) { - return vec.divide(c); + return vec.divide(c); } void operator+=(Vector2& vec1, const Vector2& vec2) { - vec1.x += vec2.x; - vec1.y += vec2.y; + vec1.x += vec2.x; + vec1.y += vec2.y; } void operator-=(Vector2& vec1, const Vector2& vec2) { - vec1.x -= vec2.x; - vec1.y -= vec2.y; + vec1.x -= vec2.x; + vec1.y -= vec2.y; } void operator*=(Vector2& vec, float c) { - vec.x *= c; - vec.y *= c; + vec.x *= c; + vec.y *= c; } void operator/=(Vector2& vec, float c) { - vec.x /= c; - vec.y /= c; + vec.x /= c; + vec.y /= c; } diff --git a/src/Vector2.h b/src/Vector2.h index d2bc2a0..2d1e85b 100644 --- a/src/Vector2.h +++ b/src/Vector2.h @@ -15,6 +15,7 @@ class Vector2 Vector2(); Vector2(float, float); Vector2(const Vector2&); + ~Vector2(); void zero(); void unit(); @@ -32,8 +33,10 @@ class Vector2 }; /// ***** Header Methods ***** -// definitions of the operators are external -// because (float, Vector2) would fail inside class + +// definitions of the operators are external because (float, Vector2) would +// fail inside the class + Vector2 operator+(const Vector2&, const Vector2&); Vector2 operator-(const Vector2&, const Vector2&); Vector2 operator*(float, const Vector2&); diff --git a/src/codingstyle.txt b/src/codingstyle.txt index f1da776..b2fda27 100644 --- a/src/codingstyle.txt +++ b/src/codingstyle.txt @@ -18,20 +18,24 @@ This is in a very short form as it's mostly for myself. - sections of a file should be commented with the following where appropriate - they should appear in this order - - they should have two newlines before star lines, excluding the first + - they should have a newline above and below star lines +Headers: +/// ***** Header Class ***** +/// ***** Header Methods ***** + +Source: /// ***** Private Method Headers ***** /// ***** Private Variables ***** -/// ***** Constructors/Destructors ***** +/// ***** MAIN Method ***** -/// ***** Public Methods ***** -/// ***** Private Methods ***** +/// ***** Constructors/Destructors ***** +/// ***** Initializers/Cleaners ***** /// ***** Public Class Methods ***** /// ***** Protected Class Methods ***** /// ***** Private Class Methods ***** - -/// ***** Header Class ***** -/// ***** Header Methods ***** +/// ***** Public Methods ***** +/// ***** Private Methods ***** diff --git a/src/debug.h b/src/debug.h index 1a9fc02..a0bfecb 100644 --- a/src/debug.h +++ b/src/debug.h @@ -1,15 +1,17 @@ #ifndef DEBUG_H #define DEBUG_H +#include +using std::cerr; +using std::cout; +using std::endl; + + // comment out when not debugging #define DEBUGGING // comment out to prevent FPS and UPS printing #define FPSUPS -#include -using std::cerr; -using std::cout; -using std::endl; #endif // DEBUG_H diff --git a/src/effectManager.cpp b/src/effectManager.cpp index c22510a..bead165 100644 --- a/src/effectManager.cpp +++ b/src/effectManager.cpp @@ -5,10 +5,11 @@ #include "Effects/Screen.h" /// ***** Private Variables ***** + Effect** effects; int numEffects; -/// ***** Public Methods ***** +/// ***** Initializers/Cleaners ***** void effect::init() { @@ -28,6 +29,8 @@ void effect::clean() delete[] effects; } +/// ***** Public Methods ***** + Vector2 effect::positionDelta(const PhysicsEntity* e, float time_step) { Vector2 acc(0,0); diff --git a/src/effectManager.h b/src/effectManager.h index 0157e24..d00d3ec 100644 --- a/src/effectManager.h +++ b/src/effectManager.h @@ -14,4 +14,5 @@ namespace effect Vector2 velocityDelta(const PhysicsEntity*, float); Vector2 forceDelta(const PhysicsEntity*, float); } + #endif // EFFECTMANAGER_H diff --git a/src/entityCreator.cpp b/src/entityCreator.cpp index a183d87..0247f04 100644 --- a/src/entityCreator.cpp +++ b/src/entityCreator.cpp @@ -6,13 +6,13 @@ #include "Entities/Ball.h" #include "graphics/colors.h" -/// ***** Private Method Headers ***** +/// ***** Private Variables ***** + typedef std::queue queBall; queBall Balls; -/// ***** Private Variables ***** +/// ***** Initializers/Cleaners ***** -/// ***** Public Methods ***** void creator::init() { Ball* ball; @@ -76,13 +76,15 @@ void creator::clean() removeAllBalls(); } +/// ***** Public Methods ***** + void creator::addBall() { - + //TODO } void creator::removeBall() { - + //TODO } void creator::removeAllBalls() { diff --git a/src/entityCreator.h b/src/entityCreator.h index 5e19eca..acad0f5 100644 --- a/src/entityCreator.h +++ b/src/entityCreator.h @@ -1,7 +1,6 @@ #ifndef ENTITYCREATOR_H #define ENTITYCREATOR_H -//#include "Entities/Entity.h" /// ***** Header Methods ***** namespace creator diff --git a/src/entityManager.cpp b/src/entityManager.cpp index 5fe9878..b646c1a 100644 --- a/src/entityManager.cpp +++ b/src/entityManager.cpp @@ -9,23 +9,23 @@ #include "Entities/PhysicsEntity.h" /// ***** Private Method Headers ***** + void updateParticles(float); void updatePhysics(float); /// ***** Private Variables ***** + typedef std::set setPart; setPart particles_To_Add; setPart active_Particles; setPart particles_To_Remove; -bool clearParticles; typedef std::set setPhys; setPhys physics_To_Add; setPhys active_Physics; setPhys physics_To_Remove; -bool clearPhysics; -/// ***** Public Methods ***** +/// ***** Initializers/Cleaners ***** void manager::init() { @@ -36,6 +36,8 @@ void manager::clean() } +/// ***** Public Methods ***** + void manager::add(Entity* e) { { @@ -83,12 +85,6 @@ void manager::remove(Entity* e) std::cerr << std::endl; } -void manager::clear() -{ - clearParticles = true; - clearPhysics = true; -} - void manager::handleInput() { // TODO @@ -115,10 +111,10 @@ void manager::draw() { (*it)->draw(); } - } /// ***** Private Methods ***** + void updateParticles(float time_step) { // add new Particle*s to Active diff --git a/src/entityManager.h b/src/entityManager.h index 04d4a1c..f841ab9 100644 --- a/src/entityManager.h +++ b/src/entityManager.h @@ -12,7 +12,6 @@ namespace manager // does not new or delete Entities void add(Entity*); void remove(Entity*); - void clear(); void update(float); void draw(); diff --git a/src/graphics/colors.h b/src/graphics/colors.h index 03e76ea..803e090 100644 --- a/src/graphics/colors.h +++ b/src/graphics/colors.h @@ -1,4 +1,6 @@ +/// ***** Public Variables ***** + 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}; diff --git a/src/graphics/graphics.cpp b/src/graphics/graphics.cpp index ab7f08f..32811c3 100644 --- a/src/graphics/graphics.cpp +++ b/src/graphics/graphics.cpp @@ -1,20 +1,20 @@ #include "graphics.h" +#include "../debug.h" #include #include #include #include -#include "../debug.h" - -static const float PI = 3.1415926535897; +#include "../mathw.h" /// ***** Private Method Headers ***** + void drawCircle(int); void sdlInit(); void glInit(); -/// ***** Public Methods ***** +/// ***** Initializers/Cleaners ***** void graphicsInit() { @@ -22,11 +22,13 @@ void graphicsInit() glInit(); } -void graphicsCleanUp() +void graphicsClean() { } +/// ***** Public Methods ***** + void glDrawCircle(float radius, const Vector2& vec, const float* color) { glMatrixMode(GL_MODELVIEW); diff --git a/src/graphics/graphics.h b/src/graphics/graphics.h index b42617c..07b317a 100644 --- a/src/graphics/graphics.h +++ b/src/graphics/graphics.h @@ -4,8 +4,9 @@ #include "../Vector2.h" /// ***** Header Methods ***** + void graphicsInit(); -void graphicsCleanUp(); +void graphicsClean(); void glDrawCircle(float radius, const Vector2&, const float* color = 0); diff --git a/src/handleSignal.cpp b/src/handleSignal.cpp index d449b8a..5677e9e 100644 --- a/src/handleSignal.cpp +++ b/src/handleSignal.cpp @@ -4,8 +4,8 @@ #include /// ***** Private Method Headers ***** -void sighandler( int sig ); +void sighandler( int sig ); /// ***** Public Methods ***** diff --git a/src/init.h b/src/init.h deleted file mode 100644 index 824f8b7..0000000 --- a/src/init.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef INIT_H -#define INIT_H - -/// ***** Header Methods ***** -void initGraphics(); -int initMouse(); -void initKeyboard(); - -void cleanGraphics(); -void cleanMouse(); -void cleanKeyboard(); - -#endif // INIT_H diff --git a/src/input/inputManager.cpp b/src/input/inputManager.cpp index e8b92c6..cff17c9 100644 --- a/src/input/inputManager.cpp +++ b/src/input/inputManager.cpp @@ -1,7 +1,9 @@ - #include "inputManager.h" #include "../debug.h" + +/// ***** Private Variables ***** + enum State { isR, @@ -13,11 +15,19 @@ enum State static const int keySize = 323; static State keyState[keySize]; +/// ***** Initializers/Cleaners ***** + void inputInit() { for(int i=0; i< keySize; i++) keyState[i] = isR; } +void inputClean() +{ + +} + +/// ***** Public Methods ***** void inputUpdate() { diff --git a/src/input/inputManager.h b/src/input/inputManager.h index 411dcc2..8e708d9 100644 --- a/src/input/inputManager.h +++ b/src/input/inputManager.h @@ -4,6 +4,10 @@ #include /// ***** Header Methods ***** + +void inputInit(); +void inputClean(); + void inputUpdate(); bool isPressed(Uint8); diff --git a/src/main.cpp b/src/main.cpp index 0f186bd..6f5ed03 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -11,15 +11,14 @@ #include "graphics/graphics.h" #include "input/inputManager.h" - - /// ***** Private Method Headers ***** + void init(); void sighandler( int sig ); void run(); -void cleanUp(); +void clean(); void blockUpdate(); void updateFPSCounters(); @@ -28,17 +27,6 @@ void input(); void update(float); void draw(); - -/// ***** MAIN Method ***** -int main() -{ - init(); - run(); - cleanUp(); - return 0; -} - - /// ***** Private Variables ***** // variable used to determine if it is time to shutdown @@ -64,7 +52,17 @@ int update_Count, draw_Count; long int last_Second; -/// ***** Private Methods ***** +/// ***** MAIN Method ***** +int main() +{ + init(); + run(); + clean(); + return 0; +} + +/// ***** Initializers/Cleaners ***** + void init() { installSignal(); @@ -73,22 +71,28 @@ void init() gameInit(); + inputInit(); + #ifdef DEBUGGING cout << "Initialization Complete" << endl; #endif } -void cleanUp() +void clean() { #ifdef DEBUGGING cout << "Cleaning up" << endl; #endif + inputClean(); + gameClean(); - graphicsCleanUp(); + graphicsClean(); } +/// ***** Private Methods ***** + void run() { is_Running = true; diff --git a/src/mathw.cpp b/src/mathw.cpp index 430a601..349f899 100644 --- a/src/mathw.cpp +++ b/src/mathw.cpp @@ -1,11 +1,6 @@ #include "mathw.h" -/// ***** Private Varibles ***** - -const float PI = 3.141592653; - - /// ***** Public Methods ***** int mod(int x, int y) @@ -13,7 +8,7 @@ int mod(int x, int y) return x % y + (x < 0 ? y : 0); } -/// Vector2 Math +// Vector2 Math Vector2 perp(const Vector2& vec) { diff --git a/src/mathw.h b/src/mathw.h index d752838..bac575a 100644 --- a/src/mathw.h +++ b/src/mathw.h @@ -5,6 +5,10 @@ #include "Vector2.h" +/// ***** Public Variables ***** + +static const float PI = 3.1415926535897; + /// ***** Header Methods ***** int mod(int,int); -- 2.10.2