@@ -71,8 +71,7 @@ void application::update()
this->part->acceleration = vec2(2.0 * PIXELS_PER_METER, 9.8 * PIXELS_PER_METER);
// Integrate the change
- this->part->velocity += (this->part->acceleration * deltaTime);
- this->part->position += (this->part->velocity * deltaTime);
+ this->part->integrate(deltaTime);
// check the particles position and keep the particule in the window.
if ( ((this->part->position.y - this->part->radius) <= 0) ||
@@ -26,6 +26,8 @@ public:
public:
particle(double x, double y, double mass): radius(4), position(x, y), mass(mass) {};
~particle() = default;
+
+ void integrate(double dt);
};
#endif /* PHYSICENGINE_PHYSICS_PARTICLE_H */
@@ -7,4 +7,11 @@
* Created by Manoël Trapier on 07/06/2022.
*/
-// TODO
+#include <physics/particle.h>
+void particle::integrate(double dt)
+{
+ this->velocity += this->acceleration * dt;
+ this->position += this->velocity * dt;
+}