T
Till Crueger
Hi,
I have the folowing code (Assuming corect constructors and accesors):
class Vector{
private:
double x;
double y;
public:
Vector operator-(Vector b);
}
Vector Vector:perator-(Vector b){
Vector result= Vector(x-b.x(),y-b.y());
return result;
}
in another method I do the following:
set Vector iBallPos to some value
set Vector iPlayerPos to some value
Vector iBallDistVec=iPlayerPos - iBallPos;
when output IBallPos, iPlayerPos and iBallDist I get the following:
Token "iBallPos.x()" is: 45.4729
Token "iBallPos.y()" is: -19.3021
Token "iPlayerPos.x()" is: 0
Token "iPlayerPos.y()" is: 0
Token "iBallDistVec.x()" is: -0.920505
Token "iBallDistVec.y()" is: 0.390731
or similar wrong values.
If anybody has any idea, what is wrong wrong with this code, please let me
know.
Till
I have the folowing code (Assuming corect constructors and accesors):
class Vector{
private:
double x;
double y;
public:
Vector operator-(Vector b);
}
Vector Vector:perator-(Vector b){
Vector result= Vector(x-b.x(),y-b.y());
return result;
}
in another method I do the following:
set Vector iBallPos to some value
set Vector iPlayerPos to some value
Vector iBallDistVec=iPlayerPos - iBallPos;
when output IBallPos, iPlayerPos and iBallDist I get the following:
Token "iBallPos.x()" is: 45.4729
Token "iBallPos.y()" is: -19.3021
Token "iPlayerPos.x()" is: 0
Token "iPlayerPos.y()" is: 0
Token "iBallDistVec.x()" is: -0.920505
Token "iBallDistVec.y()" is: 0.390731
or similar wrong values.
If anybody has any idea, what is wrong wrong with this code, please let me
know.
Till