enemy comes to you when in his radius

This commit is contained in:
Remco
2016-05-23 08:48:23 +02:00
parent a8415db4ac
commit d01efecb0e
22 changed files with 7274 additions and 21 deletions
+35
View File
@@ -1,3 +1,5 @@
#define _USE_MATH_DEFINES
#include <cmath>
#include "Vector.h"
Vec3f::Vec3f(float x, float y, float z)
@@ -6,6 +8,17 @@ Vec3f::Vec3f(float x, float y, float z)
this->y = y;
this->z = z;
}
/*The length of the vector*/
float Vec3f::Length()
{
return (float)sqrt(x*x+y*y+z*z);
}
float Vec3f::Distance(const Vec3f &other)
{
return (float)sqrt(pow(other.x - x, 2)+pow(other.y - y, 2)+pow(other.z - z, 2));
}
Vec3f::Vec3f()
{
this->x = 0;
@@ -34,6 +47,22 @@ Vec3f Vec3f::operator/(float value)
return Vec3f(x / value, y / value, z / value);
}
bool Vec3f::operator==(const Vec3f & other)
{
/*bool xb, yb,zb;
xb = x == other.x;
yb = y == other.y;
zb = z == other.z;
if (xb & yb & zb)
return true;*/
return x == other.x & y == other.y & z == other.z;
}
bool Vec3f::operator!=(const Vec3f & other)
{
return x != other.x & y != other.y & z != other.z;
}
Vec2f::Vec2f(float x, float y)
@@ -61,3 +90,9 @@ Vec2f Vec2f::operator+(const Vec2f & other)
{
return Vec2f(x + other.x, y+other.y);
}
float Vec2f::length()
{
return (float)sqrt(x*x + y*y);
}