Skip to content

Commit

Permalink
Position & Angle for particle engine (See #99)
Browse files Browse the repository at this point in the history
- position & angle added.
- thruster symmetry fixed.
  • Loading branch information
abekkine committed May 12, 2018
1 parent 604fa21 commit 485b4c2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
10 changes: 10 additions & 0 deletions testing/particle-test/ParticleManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,16 @@ class ParticleManager {
}
virtual void AddParticle() = 0;
void Render() {
glPushMatrix();
glLoadIdentity();
glTranslated(x_, y_, 0.0);
glRotated(angle_, 0.0, 0.0, 1.0);

for (auto p : particles) {
p->Render();
}

glPopMatrix();
}
void AddParticles() {
for (int i=0; i<kBurstSize; ++i) {
Expand All @@ -48,6 +55,9 @@ class ParticleManager {
protected:
const int kMaxParticles;
const int kBurstSize;
double x_;
double y_;
double angle_;
std::vector<Particle *> particles;
};

Expand Down
8 changes: 6 additions & 2 deletions testing/particle-test/Thruster.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ class Smoke : public Particle {

class Thruster : public ParticleManager {
public:
Thruster(int n, int m) : ParticleManager(n, m) {}
Thruster(int n, int m) : ParticleManager(n, m) {
x_ = 10.0;
y_ = 10.0;
angle_ = 90.0;
}
~Thruster() {}
void AddParticle() {
Smoke *p;
p = new Smoke(1.0);
double a = drand48() * M_PI / 6.0;
double a = (drand48() * M_PI / 6.0) - (M_PI / 12.0);
double s = drand48() * 10.0 + 5.0;
p->vx = s * cos(a);
p->vy = s * sin(a);
Expand Down

0 comments on commit 485b4c2

Please sign in to comment.