#include "Effect.h"
+
+/// ***** Constructors/Destructors *****
+
Effect::Effect()
{
}
+/// ***** Public Class Methods *****
+
Vector2 Effect::positionDelta(const PhysicsEntity*, float) const
{
return Vector2(0,0);
#include "../Vector2.h"
-//#include "../Entities/PhysicsEntity.h"
+
+// Mutual headers ...
class PhysicsEntity;
/// ***** Header Class *****
+
class Effect
{
protected:
#include "Gravity.h"
+
+/// ***** Constructors/Destructors *****
+
Gravity::Gravity()
{
}
+/// ***** Public Class Methods *****
+
Vector2 Gravity::forceDelta(const PhysicsEntity*, float) const
{
return Vector2(0, 0.001);
#ifndef GRAVITY_H
#define GRAVITY_H
-#include "../Vector2.h"
#include "Effect.h"
+#include "../Vector2.h"
+
/// ***** Header Class *****
+
class Gravity: public Effect
{
public:
#include "Screen.h"
-#include "../debug.h"
#include "../Entities/PhysicsEntity.h"
#include "../Entities/Ball.h"
+
+/// ***** Constructors/Destructors *****
+
Screen::Screen()
{
}
+/// ***** Public Class Methods *****
+
Vector2 Screen::velocityDelta(const PhysicsEntity* e, float time_step) const
{
const Vector2& pos = e->positionRaw();
#ifndef SCREEN_H
#define SCREEN_H
-#include "../Vector2.h"
#include "Effect.h"
+#include "../Vector2.h"
+
/// ***** Header Class *****
+
class Screen: public Effect
{
public:
#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)
{
}
+/// ***** Public Class Methods *****
+
void Ball::draw() const
{
glDrawCircle(radius, position, color);
#include "PhysicsEntity.h"
#include "../Vector2.h"
+
/// ***** Header Class *****
+
class Ball: public PhysicsEntity
{
public:
#include "Entity.h"
+
#include "../Vector2.h"
-#include <iostream>
+
+/// ***** Constructors/Destructors *****
+
+Entity::Entity(const Vector2& pos)
+ : position(pos), velocity(0,0)
+{
+
+}
+Entity::~Entity()
+{
+
+}
/// ***** Public Class Methods *****
return velocity;
}
-Entity::Entity(const Vector2& pos)
- : position(pos), velocity(0,0)
-{
-
-}
-Entity::~Entity()
-{
-
-}
#include "../Vector2.h"
+
/// ***** Header Class *****
+
class Entity
{
protected:
#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)
{
}
+/// ***** Public Class Methods *****
+
void Line::draw()
{
// TODO
#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:
#include "Particle.h"
+
#include "../Vector2.h"
-/// ***** Public Class Methods *****
+
+/// ***** Constructors/Destructors *****
+
Particle::Particle(const Vector2& pos, bool canDie)
: Entity(pos), canDie(canDie)
{
}
+/// ***** Public Class Methods *****
+
void Particle::update(float time_step)
{
if(isDead)
#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:
#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);
#include "Entity.h"
#include "../Vector2.h"
+
/// ***** Header Class *****
+
class PhysicsEntity: public Entity
{
protected:
#include "Point.h"
+
#include "../Vector2.h"
-/// ***** Public Class Methods *****
+
+/// ***** Constructors/Destructors *****
+
Point::Point(const Vector2& org, bool canDie)
: Particle(org, canDie), radius(2)
{
}
+/// ***** Public Class Methods *****
+
void Point::draw()
{
// TODO
#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:
#include "Polygon.h"
+
#include "../Vector2.h"
-/// ***** Public Class Methods *****
+
+/// ***** Constructors/Destructors *****
+
Polygon::Polygon(const Vector2& pos, vector<Vector2> 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
}
#include <vector>
using std::vector;
+
/// ***** Header Class *****
+
class Polygon: public PhysicsEntity
{
public:
// color;
private:
- void CreateBindingBox();
+ void createBindingBox();
};
#endif // POLYGON_H
#include "WindParticle.h"
+
#include "../Vector2.h"
-/// ***** Public Class Methods *****
+
+/// ***** Constructors/Destructors *****
+
WindParticle::WindParticle(const Vector2& org, float life_time)
: Point(org, life_time)
{
}
+/// ***** Public Class Methods *****
+
void WindParticle::update(float time_step)
{
Point::update(time_step);
#include "Point.h"
#include "../Vector2.h"
+
/// ***** Header Class *****
+
class WindParticle: public Point
{
public:
#include "CreatingPolygon.h"
+
/// ***** Constructors/Destructors *****
+
CreatingPolygon::CreatingPolygon()
{
}
/// ***** Public Class Methods *****
+
void CreatingPolygon::handleInput(bool on_top) const
{
// TODO
#include "GameState.h"
+
/// ***** Header Class *****
+
class CreatingPolygon : public GameState
{
public:
#include "GameState.h"
+
/// ***** Constructors/Destructors *****
+
GameState::GameState()
{
#ifndef GAMESTATE_H
#define GAMESTATE_H
+
/// ***** Header Class *****
+
class GameState
{
protected:
#include "Paused.h"
+
/// ***** Constructors/Destructors *****
+
Paused::Paused()
{
}
/// ***** Public Class Methods *****
+
void Paused::handleInput(bool on_top) const
{
// TODO
#include "GameState.h"
+
/// ***** Header Class *****
+
class Paused : public GameState
{
public:
#include "../entityManager.h"
+
/// ***** Constructors/Destructors *****
+
Running::Running()
{
manager::init();
}
/// ***** Public Class Methods *****
+
void Running::handleInput(bool on_top) const
{
if( on_top )
#include "GameState.h"
+
/// ***** Header Class *****
+
class Running : public GameState
{
public:
#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;
}
Vector2();
Vector2(float, float);
Vector2(const Vector2&);
+ ~Vector2();
void zero();
void unit();
};
/// ***** 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&);
- 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 *****
#ifndef DEBUG_H
#define DEBUG_H
+#include <iostream>
+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 <iostream>
-using std::cerr;
-using std::cout;
-using std::endl;
#endif // DEBUG_H
#include "Effects/Screen.h"
/// ***** Private Variables *****
+
Effect** effects;
int numEffects;
-/// ***** Public Methods *****
+/// ***** Initializers/Cleaners *****
void effect::init()
{
delete[] effects;
}
+/// ***** Public Methods *****
+
Vector2 effect::positionDelta(const PhysicsEntity* e, float time_step)
{
Vector2 acc(0,0);
Vector2 velocityDelta(const PhysicsEntity*, float);
Vector2 forceDelta(const PhysicsEntity*, float);
}
+
#endif // EFFECTMANAGER_H
#include "Entities/Ball.h"
#include "graphics/colors.h"
-/// ***** Private Method Headers *****
+/// ***** Private Variables *****
+
typedef std::queue<Ball*> queBall;
queBall Balls;
-/// ***** Private Variables *****
+/// ***** Initializers/Cleaners *****
-/// ***** Public Methods *****
void creator::init()
{
Ball* ball;
removeAllBalls();
}
+/// ***** Public Methods *****
+
void creator::addBall()
{
-
+ //TODO
}
void creator::removeBall()
{
-
+ //TODO
}
void creator::removeAllBalls()
{
#ifndef ENTITYCREATOR_H
#define ENTITYCREATOR_H
-//#include "Entities/Entity.h"
/// ***** Header Methods *****
namespace creator
#include "Entities/PhysicsEntity.h"
/// ***** Private Method Headers *****
+
void updateParticles(float);
void updatePhysics(float);
/// ***** Private Variables *****
+
typedef std::set<Particle*> setPart;
setPart particles_To_Add;
setPart active_Particles;
setPart particles_To_Remove;
-bool clearParticles;
typedef std::set<PhysicsEntity*> setPhys;
setPhys physics_To_Add;
setPhys active_Physics;
setPhys physics_To_Remove;
-bool clearPhysics;
-/// ***** Public Methods *****
+/// ***** Initializers/Cleaners *****
void manager::init()
{
}
+/// ***** Public Methods *****
+
void manager::add(Entity* e)
{
{
std::cerr << std::endl;
}
-void manager::clear()
-{
- clearParticles = true;
- clearPhysics = true;
-}
-
void manager::handleInput()
{
// TODO
{
(*it)->draw();
}
-
}
/// ***** Private Methods *****
+
void updateParticles(float time_step)
{
// add new Particle*s to Active
// does not new or delete Entities
void add(Entity*);
void remove(Entity*);
- void clear();
void update(float);
void draw();
+/// ***** 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};
#include "graphics.h"
+#include "../debug.h"
#include <GL/gl.h>
#include <GL/glu.h>
#include <SDL/SDL.h>
#include <cmath>
-#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()
{
glInit();
}
-void graphicsCleanUp()
+void graphicsClean()
{
}
+/// ***** Public Methods *****
+
void glDrawCircle(float radius, const Vector2& vec, const float* color)
{
glMatrixMode(GL_MODELVIEW);
#include "../Vector2.h"
/// ***** Header Methods *****
+
void graphicsInit();
-void graphicsCleanUp();
+void graphicsClean();
void glDrawCircle(float radius, const Vector2&, const float* color = 0);
#include <signal.h>
/// ***** Private Method Headers *****
-void sighandler( int sig );
+void sighandler( int sig );
/// ***** Public Methods *****
+++ /dev/null
-#ifndef INIT_H
-#define INIT_H
-
-/// ***** Header Methods *****
-void initGraphics();
-int initMouse();
-void initKeyboard();
-
-void cleanGraphics();
-void cleanMouse();
-void cleanKeyboard();
-
-#endif // INIT_H
-
#include "inputManager.h"
#include "../debug.h"
+
+/// ***** Private Variables *****
+
enum State
{
isR,
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()
{
#include <SDL/SDL.h>
/// ***** Header Methods *****
+
+void inputInit();
+void inputClean();
+
void inputUpdate();
bool isPressed(Uint8);
#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();
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
long int last_Second;
-/// ***** Private Methods *****
+/// ***** MAIN Method *****
+int main()
+{
+ init();
+ run();
+ clean();
+ return 0;
+}
+
+/// ***** Initializers/Cleaners *****
+
void init()
{
installSignal();
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;
#include "mathw.h"
-/// ***** Private Varibles *****
-
-const float PI = 3.141592653;
-
-
/// ***** Public Methods *****
int mod(int x, int y)
return x % y + (x < 0 ? y : 0);
}
-/// Vector2 Math
+// Vector2 Math
Vector2 perp(const Vector2& vec)
{
#include "Vector2.h"
+/// ***** Public Variables *****
+
+static const float PI = 3.1415926535897;
+
/// ***** Header Methods *****
int mod(int,int);