From: Patrik Gornicz Date: Sat, 19 Jul 2008 21:39:49 +0000 (-0400) Subject: change Vector2 param to a const Vector2& X-Git-Tag: physics-premerge~188 X-Git-Url: http://gitweb.pgornicz.com/gitweb.cgi?a=commitdiff_plain;h=5f1f55d185e7587999ec4755c00d133a140d7de2;p=libbear.git change Vector2 param to a const Vector2& --- diff --git a/src/Entities/Ball.cpp b/src/Entities/Ball.cpp index ad24d8e..7b75839 100644 --- a/src/Entities/Ball.cpp +++ b/src/Entities/Ball.cpp @@ -1,10 +1,12 @@ #include "Ball.h" +#include "../debug.h" + #include "../Vector2.h" #include "../graphics/graphics.h" /// ***** Public Class Methods ***** -Ball::Ball(Vector2 pos, float radius) - : PhysicsEntity(pos), radius(radius) +Ball::Ball(const Vector2& pos, float radius, const float* color) + : PhysicsEntity(pos), radius(radius), color(color) { } @@ -15,7 +17,5 @@ Ball::~Ball() void Ball::draw() const { - // TODO - - glDrawCircle(radius, &position); + glDrawCircle(radius, &position, color); } diff --git a/src/Entities/Ball.h b/src/Entities/Ball.h index 8a1b1c8..8312c95 100644 --- a/src/Entities/Ball.h +++ b/src/Entities/Ball.h @@ -8,14 +8,14 @@ class Ball: public PhysicsEntity { public: - Ball(Vector2, float); + Ball(const Vector2&, float radius, const float* color); virtual ~Ball(); virtual void draw() const; protected: float radius; - // color; + const float* color; }; #endif // BALL_H diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index d652e2d..462fcd0 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -5,7 +5,7 @@ /// ***** Public Class Methods ***** -Entity::Entity(Vector2 pos) +Entity::Entity(const Vector2& pos) : position(pos), velocity(0,0) { diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index d697803..65fe632 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -7,7 +7,7 @@ class Entity { protected: - Entity(Vector2); + Entity(const Vector2&); public: virtual ~Entity(); diff --git a/src/Entities/Line.cpp b/src/Entities/Line.cpp index 14f1526..4814eff 100644 --- a/src/Entities/Line.cpp +++ b/src/Entities/Line.cpp @@ -2,12 +2,12 @@ #include "../Vector2.h" /// ***** Public Class Methods ***** -Line::Line(Vector2 org, Vector2 dest, bool canDie) +Line::Line(const Vector2& org, const Vector2& dest, bool canDie) : Particle(org, canDie), dest(dest) { } -Line::Line(Vector2 org, Vector2 dest, float life_time) +Line::Line(const Vector2& org, const Vector2& dest, float life_time) : Particle(org, life_time), dest(dest) { diff --git a/src/Entities/Line.h b/src/Entities/Line.h index 19ad61d..5798655 100644 --- a/src/Entities/Line.h +++ b/src/Entities/Line.h @@ -13,8 +13,8 @@ class Line: public Particle { public: - Line(Vector2, Vector2, bool=true); - Line(Vector2, Vector2, float); + Line(const Vector2&, const Vector2&, bool=true); + Line(const Vector2&, const Vector2&, float); virtual ~Line(); virtual void draw(); diff --git a/src/Entities/Particle.cpp b/src/Entities/Particle.cpp index 9322314..da9a6d1 100644 --- a/src/Entities/Particle.cpp +++ b/src/Entities/Particle.cpp @@ -2,12 +2,12 @@ #include "../Vector2.h" /// ***** Public Class Methods ***** -Particle::Particle(Vector2 pos, bool canDie) +Particle::Particle(const Vector2& pos, bool canDie) : Entity(pos), canDie(canDie) { } -Particle::Particle(Vector2 pos, float lifeTime) +Particle::Particle(const Vector2& pos, float lifeTime) : Entity(pos), lifeTime(lifeTime) { diff --git a/src/Entities/Particle.h b/src/Entities/Particle.h index de5176a..76c7187 100644 --- a/src/Entities/Particle.h +++ b/src/Entities/Particle.h @@ -13,8 +13,8 @@ class Particle: public Entity { protected: - Particle(Vector2, bool=true); - Particle(Vector2, float); + Particle(const Vector2&, bool=true); + Particle(const Vector2&, float); public: virtual ~Particle(); diff --git a/src/Entities/PhysicsEntity.cpp b/src/Entities/PhysicsEntity.cpp index 2eadc34..00817b4 100644 --- a/src/Entities/PhysicsEntity.cpp +++ b/src/Entities/PhysicsEntity.cpp @@ -2,7 +2,7 @@ #include "../Vector2.h" /// ***** Public Class Methods ***** -PhysicsEntity::PhysicsEntity(Vector2 pos) +PhysicsEntity::PhysicsEntity(const Vector2& pos) : Entity(pos) { diff --git a/src/Entities/PhysicsEntity.h b/src/Entities/PhysicsEntity.h index 49849ab..dd6455b 100644 --- a/src/Entities/PhysicsEntity.h +++ b/src/Entities/PhysicsEntity.h @@ -8,7 +8,7 @@ class PhysicsEntity: public Entity { protected: - PhysicsEntity(Vector2); + PhysicsEntity(const Vector2&); public: virtual ~PhysicsEntity(); diff --git a/src/Entities/Point.cpp b/src/Entities/Point.cpp index 1c4692f..63334ea 100644 --- a/src/Entities/Point.cpp +++ b/src/Entities/Point.cpp @@ -2,12 +2,12 @@ #include "../Vector2.h" /// ***** Public Class Methods ***** -Point::Point(Vector2 org, bool canDie) +Point::Point(const Vector2& org, bool canDie) : Particle(org, canDie), radius(2) { } -Point::Point(Vector2 org, float life_time) +Point::Point(const Vector2& org, float life_time) : Particle(org, life_time), radius(2) { diff --git a/src/Entities/Point.h b/src/Entities/Point.h index 65173b1..459729c 100644 --- a/src/Entities/Point.h +++ b/src/Entities/Point.h @@ -13,8 +13,8 @@ class Point: public Particle { public: - Point(Vector2, bool=true); - Point(Vector2, float); + Point(const Vector2&, bool=true); + Point(const Vector2&, float); virtual ~Point(); virtual void draw(); diff --git a/src/Entities/Polygon.cpp b/src/Entities/Polygon.cpp index bd2a38d..dc25174 100644 --- a/src/Entities/Polygon.cpp +++ b/src/Entities/Polygon.cpp @@ -2,7 +2,7 @@ #include "../Vector2.h" /// ***** Public Class Methods ***** -Polygon::Polygon(Vector2 pos, vector points) +Polygon::Polygon(const Vector2& pos, vector points) : PhysicsEntity(pos), points(points) { CreateBindingBox(); diff --git a/src/Entities/Polygon.h b/src/Entities/Polygon.h index c6714fa..c457803 100644 --- a/src/Entities/Polygon.h +++ b/src/Entities/Polygon.h @@ -11,7 +11,7 @@ using std::vector; class Polygon: public PhysicsEntity { public: - Polygon(Vector2, vector); + Polygon(const Vector2&, vector); virtual ~Polygon(); virtual void draw() const; diff --git a/src/Entities/WindParticle.cpp b/src/Entities/WindParticle.cpp index 25b48ed..91b0dfa 100644 --- a/src/Entities/WindParticle.cpp +++ b/src/Entities/WindParticle.cpp @@ -2,7 +2,7 @@ #include "../Vector2.h" /// ***** Public Class Methods ***** -WindParticle::WindParticle(Vector2 org, float life_time) +WindParticle::WindParticle(const Vector2& org, float life_time) : Point(org, life_time) { diff --git a/src/Entities/WindParticle.h b/src/Entities/WindParticle.h index 5440bb4..c39bc40 100644 --- a/src/Entities/WindParticle.h +++ b/src/Entities/WindParticle.h @@ -8,7 +8,7 @@ class WindParticle: public Point { public: - WindParticle(Vector2, float); + WindParticle(const Vector2&, float); virtual ~WindParticle(); virtual void update(float);