Add project files.

This commit is contained in:
2018-06-25 21:48:45 -04:00
parent b04a25689b
commit 3c1b7d28e8
425 changed files with 35333 additions and 0 deletions
@@ -0,0 +1,39 @@
#include "Vector2.hpp"
/*** Custom Header File ***/
#include "../iVector/iVector2.hpp"
using MathEngine::Vector2;
using MathEngine::iVector2;
Vector2::Vector2( const float X /*= 0.0f*/, const float Y /*= 0.0f*/ )
: x(X), y(Y)
{};
Vector2::Vector2( const SDL_Rect& copy )
{
x = float(copy.x);
y = float(copy.y);
}
Vector2& Vector2::operator=( const SDL_Rect& copy )
{
x = float(copy.x);
y = float(copy.y);
return *this;
}
Vector2::Vector2( const iVector2& copy )
{
x = float(copy.x);
y = float(copy.y);
}
Vector2& Vector2::operator=( const iVector2& copy )
{
x = float(copy.x);
y = float(copy.y);
return *this;
}
@@ -0,0 +1,29 @@
#ifndef _VECTOR2_HPP_
#define _VECTOR2_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** DLL Header File ***/
#include "dllExport.h"
namespace MathEngine {
struct iVector2;
struct EXPORT_FROM_MYDLL Vector2
{
Vector2( const float X = 0.0f, const float Y = 0.0f );
Vector2( const SDL_Rect& copy );
Vector2& operator=( const SDL_Rect& copy );
Vector2( const iVector2& copy );
Vector2& operator=( const iVector2& copy );
float x;
float y;
};/// END STRUCT DEFINITION Vector2
}/// END NAMESPACE DEFINITION MathEngine
#endif/// END IFNDEF _VECTOR2_HPP_
@@ -0,0 +1,43 @@
#include "Vector3.hpp"
/*** Custom Header File ***/
#include "../iVector/iVector3.hpp"
using MathEngine::Vector3;
using MathEngine::iVector3;
Vector3::Vector3( const float X /*= 0.0f*/, const float Y /*= 0.0f*/, const float Z /*= 0.0f*/ )
: Vector2( X, Y ), z(Z)
{}
Vector3::Vector3( const SDL_Rect& copy )
{
x = float(copy.x);
y = float(copy.y);
z = float(copy.w);
}
Vector3& Vector3::operator=( const SDL_Rect& copy )
{
x = float(copy.x);
y = float(copy.y);
z = float(copy.w);
return *this;
}
Vector3::Vector3( const iVector3& copy )
{
x = float(copy.x);
y = float(copy.y);
z = float(copy.z);
}
Vector3& Vector3::operator=( const iVector3& copy )
{
x = float(copy.x);
y = float(copy.y);
z = float(copy.z);
return *this;
}
@@ -0,0 +1,31 @@
#ifndef _VECTOR3_HPP_
#define _VECTOR3_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** DLL Header File ***/
#include "dllExport.h"
/*** Custom Header File ***/
#include "Vector2.hpp"
namespace MathEngine {
struct iVector3;
struct EXPORT_FROM_MYDLL Vector3 : public Vector2
{
Vector3( const float X = 0.0f, const float Y = 0.0f, const float Z = 0.0f );
Vector3( const SDL_Rect& copy );
Vector3& operator=( const SDL_Rect& copy );
Vector3( const iVector3& copy );
Vector3& operator=( const iVector3& copy );
float z;
};/// END STRUCT DEFINITION Vector3
}/// END NAMESPACE DEFINITION MathEngine
#endif/// END IFNDEF _VECTOR3_HPP_
@@ -0,0 +1,46 @@
#include "Vector4.hpp"
#include "../iVector/iVector4.hpp"
using MathEngine::Vector4;
using MathEngine::iVector4;
Vector4::Vector4( const float X /*= 0.0f*/, const float Y /*= 0.0f*/, const float Z /*= 0.0f*/, const float W /*= 0.0f*/)
: Vector3( X, Y, Z ), w(W)
{}
Vector4::Vector4( const SDL_Rect& copy )
{
x = float(copy.x);
y = float(copy.y);
z = float(copy.w);
w = float(copy.h);
}
Vector4& Vector4::operator=( const SDL_Rect& copy )
{
x = float(copy.x);
y = float(copy.y);
z = float(copy.w);
w = float(copy.h);
return *this;
}
Vector4::Vector4( const iVector4& copy )
{
x = float(copy.x);
y = float(copy.y);
z = float(copy.z);
w = float(copy.w);
}
Vector4& Vector4::operator=( const iVector4& copy )
{
x = float(copy.x);
y = float(copy.y);
z = float(copy.z);
w = float(copy.w);
return *this;
}
@@ -0,0 +1,35 @@
#ifndef _VECTOR4_HPP_
#define _VECTOR4_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** DLL Header File ***/
#include "dllExport.h"
/*** Custom Header File ***/
#include "Vector3.hpp"
namespace MathEngine {
struct iVector4;
struct EXPORT_FROM_MYDLL Vector4 : public Vector3
{
Vector4( const float X = 0.0f, const float Y = 0.0f, const float Z = 0.0f, const float W = 0.0f );
Vector4( const SDL_Rect& copy );
Vector4& operator=( const SDL_Rect& copy );
bool operator==(const SDL_Rect& other) const;
Vector4( const iVector4& copy );
Vector4& operator=( const iVector4& copy );
bool operator==(const Vector4& other) const;
float w;
};/// END STRUCT DEFINITION Vector4
}/// END NAMESPACE DEFINITION MathEngine
#endif/// END IFNDEF _VECTOR4_HPP_
@@ -0,0 +1,200 @@
#include "cCollision.hpp"
using MathEngine::cCollision;
using MathEngine::Vector4;
using MathEngine::Vector2;
using MathEngine::iVector4;
using MathEngine::iVector2;
cCollision::cCollision()
{
}
cCollision::~cCollision()
{
}
/*static*/ const bool cCollision::BoundingBox( const SDL_Rect& a, const SDL_Rect& b )
{
if ((b.x + b.w) < a.x)
return false; //just checking if their
if ((a.x + a.w) < b.x )
return false; //bounding boxes even touch
if ((b.y + b.h) < a.y)
return false;
if ((a.y + a.h) < b.y)
return false;
return true; //bounding boxes intersect
}
/*static*/ const bool cCollision::BoundingBox( const Vector4& a, const Vector4& b )
{
if ((b.x + b.z) < a.x)
return false; //just checking if their
if ((a.x + a.z) < b.x )
return false; //bounding boxes even touch
if ((b.y + b.w) < a.y)
return false;
if ((a.y + a.w) < b.y)
return false;
return true; //bounding boxes intersect
}
/*static*/ const bool cCollision::BoundingBox( const SDL_Rect& a, const Vector4& b )
{
Vector4 temp = a;
return cCollision::BoundingBox(temp, b);
}
/*static*/ const bool cCollision::BoundingBox( const Vector4& a, const SDL_Rect& b )
{
return cCollision::BoundingBox(b, a);
}
/*static*/ const bool cCollision::BoundingBox( const iVector4& a, const iVector4& b )
{
if ((b.x + b.z) < a.x)
return false; //just checking if their
if ((a.x + a.z) < b.x )
return false; //bounding boxes even touch
if ((b.y + b.w) < a.y)
return false;
if ((a.y + a.w) < b.y)
return false;
return true; //bounding boxes intersect
}
/*static*/ const bool cCollision::BoundingBox( const SDL_Rect& a, const iVector4& b )
{
iVector4 temp = a;
return cCollision::BoundingBox(temp, b);
}
/*static*/ const bool cCollision::BoundingBox( const iVector4& a, const SDL_Rect& b )
{
return cCollision::BoundingBox(b, a);
}
/*static*/ const bool cCollision::BoundingBox( const iVector4& a, const Vector4& b )
{
Vector4 temp = a;
return cCollision::BoundingBox( temp, b );
}
/*static*/ const bool cCollision::BoundingBox( const Vector4& a, const iVector4& b )
{
return cCollision::BoundingBox( b, a );
}
/*static*/ const Vector2 cCollision::Inside( const SDL_Rect& a, const SDL_Rect& b )
{
Vector2 rtn;
rtn.x = 0.0f;
rtn.y = 0.0f;
//Check if left side of b is inside of a
if (b.x < a.x)
rtn.x = (float)(b.x - a.x);
//Check if right side of b is inside of a
if ((b.x + b.w) > (a.x + a.w))
rtn.x = (float)((b.x + b.w) - (a.x + a.w));
//Check if top side of b is inside of a
if (b.y < a.y)
rtn.y = (float)(b.y - a.y);
//Check if botton side of b is inside of a
if ((b.y + b.h) > (a.y + a.h))
rtn.y = (float)((b.y + b.h) - (a.y + a.h));
return rtn;
}
/*static*/ const Vector2 cCollision::Inside( const Vector4& a, const Vector4& b )
{
Vector2 rtn;
rtn.x = 0.0f;
rtn.y = 0.0f;
//Check if left side of b is inside of a
if (b.x < a.x)
rtn.x = a.x - b.x;
//Check if right side of b is inside of a
if ((b.x + b.z) > (a.x + a.z))
rtn.x = (a.x + a.z) - (b.x + b.z);
//Check if top side of b is inside of a
if (b.y < a.y)
rtn.y = a.y - b.y;
//Check if botton side of b is inside of a
if ((b.y + b.w) > (a.y + a.w))
rtn.y = (a.y + a.w) - (b.y + b.w);
return rtn;
}
/*static*/ const Vector2 cCollision::Inside( const SDL_Rect& a, const Vector4& b )
{
Vector4 temp = a;
return cCollision::Inside(temp, b);
}
/*static*/ const Vector2 cCollision::Inside( const Vector4& a, const SDL_Rect& b )
{
Vector4 temp = b;
return cCollision::Inside(a, temp);
}
/*static*/ const iVector2 cCollision::Inside( const iVector4& a, const iVector4& b )
{
iVector2 rtn;
rtn.x = 0;
rtn.y = 0;
//Check if left side of b is inside of a
if (b.x < a.x)
rtn.x = b.x - a.x;
//Check if right side of b is inside of a
if ((b.x + b.z) > (a.x + a.z))
rtn.x = (b.x + b.z) - (a.x + a.z);
//Check if top side of b is inside of a
if (b.y < a.y)
rtn.y = b.y - a.y;
//Check if botton side of b is inside of a
if ((b.y + b.w) > (a.y + a.w))
rtn.y = (b.y + b.w) - (a.y + a.w);
return rtn;
}
/*static*/ const iVector2 cCollision::Inside( const SDL_Rect& a, const iVector4& b )
{
iVector4 temp = a;
return cCollision::Inside( temp, b );
}
/*static*/ const iVector2 cCollision::Inside( const iVector4& a, const SDL_Rect& b )
{
return cCollision::Inside( b, a );
}
/*static*/ const Vector2 cCollision::Inside( const iVector4& a, const Vector4& b )
{
Vector4 temp = a;
return cCollision::Inside( temp, b );
}
/*static*/ const Vector2 cCollision::Inside( const Vector4& a, const iVector4& b )
{
return cCollision::Inside( b, a );
}
@@ -0,0 +1,50 @@
#ifndef _CCOLLISION_HPP_
#define _CCOLLISION_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** DLL Header File ***/
#include "dllExport.h"
/*** Custom Header File ***/
#include "Vector/Vector2.hpp"
#include "iVector/iVector2.hpp"
#include "Vector/Vector4.hpp"
#include "iVector/iVector4.hpp"
namespace MathEngine {
class EXPORT_FROM_MYDLL cCollision
{
private:
cCollision();
~cCollision();
public:
///Functions
static const bool BoundingBox( const SDL_Rect& a, const SDL_Rect& b );
static const bool BoundingBox( const Vector4& a, const Vector4& b );
static const bool BoundingBox( const SDL_Rect& a, const Vector4& b );
static const bool BoundingBox( const Vector4& a, const SDL_Rect& b );
static const bool BoundingBox( const iVector4& a, const iVector4& b );
static const bool BoundingBox( const SDL_Rect& a, const iVector4& b );
static const bool BoundingBox( const iVector4& a, const SDL_Rect& b );
static const bool BoundingBox( const iVector4& a, const Vector4& b );
static const bool BoundingBox( const Vector4& a, const iVector4& b );
static const Vector2 Inside( const SDL_Rect& a, const SDL_Rect& b );
static const Vector2 Inside( const Vector4& a, const Vector4& b );
static const Vector2 Inside( const SDL_Rect& a, const Vector4& b );
static const Vector2 Inside( const Vector4& a, const SDL_Rect& b );
static const iVector2 Inside( const iVector4& a, const iVector4& b );
static const iVector2 Inside( const SDL_Rect& a, const iVector4& b );
static const iVector2 Inside( const iVector4& a, const SDL_Rect& b );
static const Vector2 Inside( const iVector4& a, const Vector4& b );
static const Vector2 Inside( const Vector4& a, const iVector4& b );
};/// END CLASS DEFINITION cCollision
}/// END NAMESPACE DEFINITION MathEngine
#endif/// END IFNDEF _CCOLLISION_HPP_
@@ -0,0 +1,47 @@
#include "cRandom.hpp"
/*** ANSI C Header Files ***/
#include <stdlib.h>
#include <time.h>
using MathEngine::cRandom;
/*static*/ cRandom* cRandom::sp_inst = nullptr;
cRandom::cRandom()
{
Setup();
}
cRandom::~cRandom()
{}
/*static*/ cRandom& cRandom::Inst()
{
if (sp_inst == nullptr)
sp_inst = new cRandom();
return *sp_inst;
}
/*static*/ void cRandom::Delete()
{
delete sp_inst;
sp_inst = nullptr;
}
const bool cRandom::Setup() const
{
bool rtn = false;
srand((unsigned int)time(nullptr));
return rtn = true;
}
const unsigned long int cRandom::Rand( const unsigned long int max, const unsigned long int min /*= 0*/ ) const
{
return (unsigned long int)rand() % max + min;
}
const float cRandom::Rand( const float max, const float min /*= 0.0f*/ ) const
{
return (float)((max - min) * rand()/(float)RAND_MAX + min);
}
@@ -0,0 +1,32 @@
#ifndef _CRANDOM_HPP_
#define _CRANDOM_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** DLL Header File ***/
#include "dllExport.h"
namespace MathEngine {
/* Singleton */
class EXPORT_FROM_MYDLL cRandom
{
private:
cRandom();
~cRandom();
public:
///Functions
static cRandom& Inst();
static void Delete();
const bool Setup() const;
const unsigned long int Rand( const unsigned long int max, const unsigned long int min = 0 ) const;
const float Rand( const float max, const float min = 0.0f ) const;
private:
static cRandom* sp_inst;// = nullptr
};/// END CLASS DEFINITION cRandom
}/// END NAMESPACE DEFINITION MathEngine
#endif/// END IFNDEF _CRANDOM_HPP_
@@ -0,0 +1,98 @@
#include "iVector2.hpp"
/*** Custom Header File ***/
#include "../Vector/Vector2.hpp"
using MathEngine::iVector2;
using MathEngine::Vector2;
iVector2::iVector2( const int X /*= 0*/, const int Y /*= 0*/ )
: x(X), y(Y)
{}
iVector2::iVector2( const Vector2& copy )
{
x = int(copy.x);
y = int(copy.y);
}
iVector2::iVector2( const SDL_Rect& copy )
{
x = int(copy.x);
y = int(copy.y);
}
iVector2& iVector2::operator = ( const Vector2& copy )
{
x = int(copy.x);
y = int(copy.y);
return *this;
}
iVector2& iVector2::operator = ( const SDL_Rect& copy )
{
x = int(copy.x);
y = int(copy.y);
return *this;
}
bool iVector2::operator == ( const iVector2& other ) const
{
bool rtn = false;
if (x == other.x)
if (y == other.y)
rtn = true;
return rtn;
}
bool iVector2::operator == ( const SDL_Rect& other ) const
{
bool rtn = false;
if (x == other.x)
if (y == other.y)
rtn = true;
return rtn;
}
iVector2& iVector2::operator += ( const iVector2& other )
{
x += int(other.x);
y += int(other.y);
return *this;
}
iVector2& iVector2::operator += ( const SDL_Rect& other )
{
x += int(other.x);
y += int(other.y);
return *this;
}
iVector2& iVector2::operator -= (const iVector2& other)
{
x -= int(other.x);
y -= int(other.y);
return *this;
}
iVector2& iVector2::operator -= (const SDL_Rect& other)
{
x -= int(other.x);
y -= int(other.y);
return *this;
}
iVector2 operator + (const iVector2& lhs, const iVector2& rhs)
{
iVector2 rs = lhs;
rs += rhs;
return rs;
}
@@ -0,0 +1,39 @@
#ifndef _IVECTOR2_HPP_
#define _IVECTOR2_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** DLL Header File ***/
#include "dllExport.h"
namespace MathEngine {
struct Vector2;
struct EXPORT_FROM_MYDLL iVector2
{
iVector2( const int X = 0, const int Y = 0 );
iVector2( const Vector2& copy );
iVector2( const SDL_Rect& copy );
iVector2& operator = ( const Vector2& copy );
iVector2& operator = ( const SDL_Rect& copy );
bool operator == ( const iVector2& other ) const;
bool operator == ( const SDL_Rect& other ) const;
iVector2& operator += ( const iVector2& other );
iVector2& operator += ( const SDL_Rect& other );
iVector2& operator -= (const iVector2& other);
iVector2& operator -= (const SDL_Rect& other);
iVector2& operator + ( const iVector2& other );
iVector2& operator + ( const SDL_Rect& other );
int x;
int y;
};/// END STRUCT DEFINITION iVector2
}/// END NAMESPACE DEFINITION MathEngine
MathEngine::iVector2 operator + (const MathEngine::iVector2& lhs, const MathEngine::iVector2& rhs);
#endif/// END IFNDEF _IVECTOR2_HPP_
@@ -0,0 +1,67 @@
#include "iVector3.hpp"
/*** Custom Header File ***/
#include "../Vector/Vector3.hpp"
using MathEngine::iVector3;
using MathEngine::Vector3;
iVector3::iVector3( const int X /*= 0*/, const int Y /*= 0*/, const int Z /*= 0*/ )
: iVector2(X, Y), z(Z)
{}
iVector3::iVector3( const iVector2& copy )
: iVector2(copy), z(0)
{}
iVector3::iVector3( const SDL_Rect& copy )
{
x = int(copy.x);
y = int(copy.y);
z = int(copy.w);
}
iVector3& iVector3::operator=( const SDL_Rect& copy )
{
x = int(copy.x);
y = int(copy.y);
z = int(copy.w);
return *this;
}
bool iVector3::operator==( const SDL_Rect& other ) const
{
bool rtn = false;
if ( x == other.x )
if ( y == other.y )
if ( z == other.w )
rtn = true;
return rtn;
}
iVector3::iVector3( const Vector3& copy )
{
x = int(copy.x);
y = int(copy.y);
z = int(copy.z);
}
iVector3& iVector3::operator=( const Vector3& copy )
{
x = int(copy.x);
y = int(copy.y);
z = int(copy.z);
return *this;
}
bool iVector3::operator==( const iVector3& other ) const
{
bool rtn = false;
if ( x == other.x )
if ( y == other.y )
if ( z == other.z )
rtn = true;
return rtn;
}
@@ -0,0 +1,37 @@
#ifndef _IVECTOR3_HPP_
#define _IVECTOR3_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** DLL Header File ***/
#include "dllExport.h"
/*** Custom Header File ***/
#include "iVector2.hpp"
namespace MathEngine {
struct Vector3;
struct EXPORT_FROM_MYDLL iVector3 : public iVector2
{
iVector3( const int X = 0, const int Y = 0, const int Z = 0);
iVector3( const iVector2& copy );
iVector3( const SDL_Rect& copy );
iVector3& operator=( const SDL_Rect& copy );
bool operator==( const SDL_Rect& other ) const;
iVector3( const Vector3& copy );
iVector3& operator=( const Vector3& copy );
bool operator==( const iVector3& other ) const;
int z;
};/// END STRUCT DEFINITION iVector3
}/// END NAMESPACE DEFINITION MathEngine
#endif/// END IFNDEF _IVECTOR3_HPP_
@@ -0,0 +1,77 @@
#include "iVector4.hpp"
/*** Custom Header File ***/
#include "../Vector/Vector4.hpp"
using MathEngine::iVector4;
using MathEngine::Vector4;
iVector4::iVector4( const int X /*= 0*/, const int Y /*= 0*/, const int Z /*= 0*/, const int W /*= 0*/ )
: iVector3(X, Y, Z), w(W)
{}
iVector4::iVector4( const iVector2& copy )
: iVector3(copy.x, copy.y, 0), w(0)
{}
iVector4::iVector4( const iVector3& copy )
: iVector3(copy), w(0)
{}
iVector4::iVector4( const SDL_Rect& copy )
{
x = int(copy.x);
y = int(copy.y);
z = int(copy.w);
w = int(copy.h);
}
iVector4& iVector4::operator=( const SDL_Rect& copy )
{
x = int(copy.x);
y = int(copy.y);
z = int(copy.w);
w = int(copy.h);
return *this;
}
bool iVector4::operator==( const SDL_Rect& other ) const
{
bool rtn = false;
if ( x == other.x )
if ( y == other.y )
if ( z == other.w )
if ( w == other.h )
rtn = true;
return rtn;
}
iVector4::iVector4( const Vector4& copy )
{
x = int(copy.x);
y = int(copy.y);
z = int(copy.z);
w = int(copy.w);
}
iVector4& iVector4::operator=( const Vector4& copy )
{
x = int(copy.x);
y = int(copy.y);
z = int(copy.z);
w = int(copy.w);
return *this;
}
bool iVector4::operator==( const iVector4& other ) const
{
bool rtn = false;
if ( x == other.x )
if ( y == other.y )
if ( z == other.z )
if ( w == other.w )
rtn = true;
return rtn;
}
@@ -0,0 +1,39 @@
#ifndef _IVECTOR4_HPP_
#define _IVECTOR4_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** DLL Header File ***/
#include "dllExport.h"
/*** Custom Header File ***/
#include "iVector3.hpp"
namespace MathEngine {
struct Vector4;
struct EXPORT_FROM_MYDLL iVector4 : public iVector3
{
iVector4( const int X = 0, const int Y = 0, const int Z = 0, const int W = 0 );
iVector4( const iVector2& copy );
iVector4( const iVector3& copy );
iVector4( const SDL_Rect& copy );
iVector4& operator=( const SDL_Rect& copy );
bool operator==( const SDL_Rect& other ) const;
iVector4( const Vector4& copy );
iVector4& operator=( const Vector4& copy );
bool operator==( const iVector4& other ) const;
int w;
};/// END STRUCT DEFINITION iVector4
}/// END NAMESPACE DEFINITION MathEngine
#endif/// END IFNDEF _IVECTOR4_HPP_