i wrote some code which only works with objects with a heading of 0 degrees right now because its not finished but when i run it it never seems to catch the collision and break the loop. I need some help, thanks in advance.
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
double x;
double y;
int Heading;
double Distance;
double xDisplacement;
double yDisplacement;
double objectX;
double objectY;
bool CalculationDone = false;
bool LoopBreak = false;
cout << "Enter object's x co-ordinate: ";
cin >> x;
cout << "\n";
cout << "Enter object's y co-ordinate: ";
cin >> y;
cout << "\n";
cout << "Enter object's heading (degrees): ";
cin >> Heading;
cout << "\n";
cout << "Enter object's distance travelled: ";
cin >> Distance;
cout << "\n";
cout << "Enter 2nd Object's x co-ordinate: ";
cin >> objectX;
cout << "\n";
cout << "Enter 2nd Object's y co-ordinate: ";
cin >> objectY;
if (Heading == 0)
{
xDisplacement = 0;
yDisplacement = 0.01;
while (LoopBreak == false)
{
if (y < Distance)
{
x += xDisplacement;
y += yDisplacement;
cout << "\n";
cout << "(";
cout << x;
cout << ",";
cout << " ";
cout << y;
cout << ")";
cout << "\n";
}
if (x == objectX && y == objectY)
{
LoopBreak = true;
cout << "Collision Detected at (";
cout << x;
cout << ",";
cout << " ";
cout << y;
cout << ")";
cout << "\n";
}
if (y >= Distance)
{
LoopBreak = true;
}
}
}
system("PAUSE");
}