fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. int main() {
  6. double start_x = 290, start_y = 394;
  7. double vel_x = -10, vel_y = -10;
  8. double grav = -4;
  9. double delta_time = 0.001;
  10.  
  11. do {
  12. vel_y += grav * delta_time;
  13. start_x += vel_x * delta_time;
  14. start_y += vel_y * delta_time;
  15. } while( start_y > 0 );
  16.  
  17. cout << "x = " << start_x << " | y = " << start_y << " | vel_x = " << vel_x << " | vel_y = " << vel_y << endl;
  18. return 0;
  19. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
x = 172.43 | y = -0.047612 | vel_x = -10 | vel_y = -57.028