#include <iostream>
using namespace std;
float sumForces(float time, float mass); //function prototype
//Use in conjunction with overview of physics engine doc
int main(void)
{
	float time = 0;
	float dt = 0.1;
	float Ftot = 0;
	float accel = 0;
	float invMass = 1;
	float vnew = 0;
	float vcurr = 0;
	float xnew = 0;
	float xcurr = 0;
	cout << "step time accel  vcurr  xcurr"<<endl;
	for (int i = 0;i < 100;i++)
	{
		Ftot = sumForces(time,invMass);
		accel=Ftot*invMass;
		vnew=vcurr + dt*accel;
		xnew =xcurr + dt*vcurr;
		//cout << time << ", " << accel << ", " << vcurr << ", " << xcurr << endl;
		vcurr = vnew;
		xcurr=xnew;
		if ((i % 10) == 0) {
			cout << "step time accel  vcurr  xcurr" << endl;
		}
			cout <<i <<", " << time << ", " << accel << ", " << vcurr << ", " << xcurr << endl;
		time = time + dt;
	}
	return 0;
}
float sumForces(float time, float invMass)
{
	float acceleration = 2 * time;  //acceleration proportional to twice the time
	return acceleration/invMass; //F=ma
}