|
@@ -23,7 +23,9 @@ void application::setup()
|
|
|
{
|
|
|
this->running = graphics::openWindow();
|
|
|
this->millisecsPreviousFrame = SDL_GetTicks();
|
|
|
- this->part = new particle(50, 100, 1.0);
|
|
|
+
|
|
|
+ this->particles.push_back(new particle(50, 100, 1.0, 4));
|
|
|
+ this->particles.push_back(new particle(50, 200, 3.0, 12));
|
|
|
}
|
|
|
|
|
|
void application::input()
|
|
@@ -80,14 +82,24 @@ void application::update()
|
|
|
|
|
|
this->part->addForce(wind);
|
|
|
|
|
|
- // Integrate the change
|
|
|
- this->part->integrate(deltaTime);
|
|
|
-
|
|
|
- // check the particles position and keep the particule in the window.
|
|
|
- if ( ((this->part->position.y - this->part->radius) <= 0) ||
|
|
|
- ((this->part->position.y + this->part->radius) >= graphics::height()))
|
|
|
+ for (auto part:this->particles)
|
|
|
{
|
|
|
- this->part->velocity.y = -this->part->velocity.y;
|
|
|
+ part->addForce(wind);
|
|
|
+ part->integrate(deltaTime);
|
|
|
+
|
|
|
+ // check the particles position and keep the particule in the window.
|
|
|
+ if ( ((part->position.y - part->radius) <= 0) ||
|
|
|
+ ((part->position.y + part->radius) >= graphics::height()))
|
|
|
+ {
|
|
|
+ part->velocity.y = -part->velocity.y;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( ((part->position.x - part->radius) <= 0) ||
|
|
|
+ ((part->position.x + part->radius) >= graphics::width()))
|
|
|
+ {
|
|
|
+ part->velocity.x = -part->velocity.x;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
if ( ((this->part->position.x - this->part->radius) <= 0) ||
|
|
@@ -101,6 +113,11 @@ void application::update()
|
|
|
void application::render()
|
|
|
{
|
|
|
graphics::clearScreen(0xFF056263);
|
|
|
+ for (auto part:this->particles)
|
|
|
+ {
|
|
|
+ graphics::draw::fillCircle(part->position.x, part->position.y, part->radius, 0xFFFFFFFF);
|
|
|
+ }
|
|
|
+
|
|
|
graphics::draw::fillCircle(this->part->position.x, this->part->position.y, 4, 0xFFFFFFFF);
|
|
|
|
|
|
graphics::renderFrame();
|
|
@@ -109,8 +126,11 @@ void application::render()
|
|
|
void application::destroy()
|
|
|
{
|
|
|
// Nothing for now.
|
|
|
+ for (auto part:this->particles)
|
|
|
+ {
|
|
|
+ delete part;
|
|
|
+ }
|
|
|
|
|
|
- graphics::closeWindow();
|
|
|
|
|
|
- delete this->part;
|
|
|
+ graphics::closeWindow();
|
|
|
}
|