diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-07-23 14:19:28 +0100 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2017-07-23 14:19:28 +0100 |
commit | daa9dc84d7fb6e7c8f84b1ee3adfaacaad7de72f (patch) | |
tree | 60909899b320f03193896b277006fb01a506629f /src/particlebody.cpp | |
parent | 85fe87aa7a52733dc80f61617bf65f22b2d98ccb (diff) | |
download | YAGE-daa9dc84d7fb6e7c8f84b1ee3adfaacaad7de72f.tar.gz YAGE-daa9dc84d7fb6e7c8f84b1ee3adfaacaad7de72f.zip |
Fixing gravity
Diffstat (limited to 'src/particlebody.cpp')
-rw-r--r-- | src/particlebody.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/particlebody.cpp b/src/particlebody.cpp index f882f279..7435737c 100644 --- a/src/particlebody.cpp +++ b/src/particlebody.cpp @@ -1,5 +1,6 @@ #include "Physics/particlebody.hpp" +#include <iostream> #include <cmath> namespace yage @@ -26,16 +27,15 @@ void ParticleBody::update() Vector2d last_acceleration=acceleration_; // update the position of the body - //position_.x+=velocity_.x*time_step+(0.5*last_acceleration.x*std::pow(time_step, 2)); - //position_.y+=velocity_.y*time_step+(0.5*last_acceleration.y*std::pow(time_step, 2)); - position_+=velocity_*time_step+(0.5*last_acceleration*std::pow(time_step, 2)); // update the acceleration if(gravity_) acceleration_=Vector2d(force_.x()/mass_, (GRAVITY+force_.y())/mass_); else - acceleration_=Vector2d(force_.x()/mass_, force_.y()/mass_); + acceleration_=Vector2d(force_.x()/mass_, force_.y()/mass_); + + std::cout<<acceleration_<<"\n"; Vector2d avg_acceleration=(acceleration_+last_acceleration)/2.0; |