diff --git a/include/entities/entity-generic.h b/include/entities/entity-generic.h index 433f6401e185b55a495437238a911fbbd7a14f5f..976de679803a0ccec77f696c9bd634a0bc18f042 100644 --- a/include/entities/entity-generic.h +++ b/include/entities/entity-generic.h @@ -5,11 +5,14 @@ class EntityGeneric { + public: EntityGeneric(); ~EntityGeneric(); private: Logger& _logger; + + const size_t m_id = 0; }; #endif // __ENTITIES__ENTITY_GENERIC_H diff --git a/include/entity-manager.h b/include/entity-manager.h new file mode 100644 index 0000000000000000000000000000000000000000..0edc7c335f31cd625e54897eed7ed49a1e4c0c42 --- /dev/null +++ b/include/entity-manager.h @@ -0,0 +1,17 @@ +#ifndef __ENTITY_MANAGER_H__ +#define __ENTITY_MANAGER_H__ + +#include <string> + +class EntityManager +{ + public: + EntityManager(); + ~EntityManager(); + void addEntity(); + void removeEntity(); + void findEntity( std::string query ); + private: +}; + +#endif // __ENTITY_MANAGER_H__ diff --git a/include/main.h b/include/main.h index 239793a21e0ba0b025de9f46e8b192586c007fbc..a7ee083d48973a94aeabf3160add421a9f57a27f 100644 --- a/include/main.h +++ b/include/main.h @@ -6,7 +6,8 @@ enum GenerationMethod { - Random + Random, + Cave }; #include "save-manager.h" @@ -16,5 +17,6 @@ enum GenerationMethod #include "chunk.h" #include "logger.h" #include "entities/entity-generic.h" +#include "maths/maths.h" #endif // MAIN_H diff --git a/include/maths/maths.h b/include/maths/maths.h new file mode 100644 index 0000000000000000000000000000000000000000..fea450c34d4a3c6ca63296c54f7043743956ca1d --- /dev/null +++ b/include/maths/maths.h @@ -0,0 +1,6 @@ +#ifndef __MATHEMATICS_INCLUDE_H__ +#define __MATHEMATICS_INCLUDE_H__ + +#include "maths/vec2.h" + +#endif // __MATHEMATICS_INCLUDE_H__ diff --git a/include/maths/vec2.h b/include/maths/vec2.h new file mode 100644 index 0000000000000000000000000000000000000000..e01f0f7b9c4172905bb6e0e114b2530983b771cd --- /dev/null +++ b/include/maths/vec2.h @@ -0,0 +1,27 @@ +#ifndef __MATHS__VEC2_H__ +#define __MATHS__VEC2_H__ + +#include <cmath> + +class Vec2 +{ + public: + float x = 0, y = 0; + Vec2(); + Vec2( float xIn, float yIn ); + + bool operator == ( const Vec2 rhs ) const; + Vec2 operator + ( const Vec2 rhs ) const; + Vec2 operator * ( const Vec2 rhs ) const; + Vec2 operator - ( const Vec2 rhs ) const; + Vec2 operator * ( const float scale ) const; + void operator += ( const Vec2 & rhs ); + void operator -= ( const Vec2 & rhs ); + void operator *= ( const Vec2 & rhs ); + void operator *= ( const float rhs ); + + float length(); + void normalise(); +}; + +#endif // __MATHS__VEC2_H__ diff --git a/src/entity-manager.cpp b/src/entity-manager.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0caccd7a0c1327183e9810674db8ea9fc3dbd561 --- /dev/null +++ b/src/entity-manager.cpp @@ -0,0 +1,7 @@ +#include "entity-manager.h" + +EntityManager::EntityManager(){} +EntityManager::~EntityManager(){} +void EntityManager::addEntity(){} +void EntityManager::removeEntity(){} +void EntityManager::findEntity( std::string query ){} diff --git a/src/maths/vec2.cpp b/src/maths/vec2.cpp new file mode 100644 index 0000000000000000000000000000000000000000..aee6719eca9998cfe71c7094beeecd8925494870 --- /dev/null +++ b/src/maths/vec2.cpp @@ -0,0 +1,32 @@ +#include "maths/vec2.h" + +Vec2::Vec2() + : Vec2( 0.0, 0.0 ) {} +Vec2::Vec2( float xIn, float yIn ) + : x( xIn ), y( yIn ) +{}; + +bool Vec2::operator == ( const Vec2 rhs ) const { + return ( + abs( this->x - rhs.x ) < 0.01 + ) && ( + abs( this->y - rhs.y ) < 0.01 + ); +} +Vec2 Vec2::operator + ( const Vec2 rhs ) const { return Vec2( this->x + rhs.x, this->y + rhs.y ); } +Vec2 Vec2::operator - ( const Vec2 rhs ) const { return Vec2( this->x - rhs.x, this->y - rhs.y ); } +Vec2 Vec2::operator * ( const Vec2 rhs ) const { return Vec2( this->x * rhs.x, this->y * rhs.y ); } +Vec2 Vec2::operator * ( const float scale ) const { return Vec2( this->x * scale, this->y * scale ); } +void Vec2::operator += ( const Vec2 & rhs ) { this->x += rhs.x; this->y += rhs.y; } +void Vec2::operator -= ( const Vec2 & rhs ) { this->x -= rhs.x; this->y -= rhs.y; } +void Vec2::operator *= ( const Vec2 & rhs ) { this->x *= rhs.x; this->y *= rhs.y; } +void Vec2::operator *= ( const float scale ) { this->x *= scale; this->y *= scale; } + +float Vec2::length() + { return sqrtf( this->x*this->x + this->y*this->y ); } +void Vec2::normalise() +{ + float mag = this->length(); + this->x /= mag; + this->y /= mag; +} diff --git a/src/maths/vec2.cpp.back b/src/maths/vec2.cpp.back new file mode 100644 index 0000000000000000000000000000000000000000..aee6719eca9998cfe71c7094beeecd8925494870 --- /dev/null +++ b/src/maths/vec2.cpp.back @@ -0,0 +1,32 @@ +#include "maths/vec2.h" + +Vec2::Vec2() + : Vec2( 0.0, 0.0 ) {} +Vec2::Vec2( float xIn, float yIn ) + : x( xIn ), y( yIn ) +{}; + +bool Vec2::operator == ( const Vec2 rhs ) const { + return ( + abs( this->x - rhs.x ) < 0.01 + ) && ( + abs( this->y - rhs.y ) < 0.01 + ); +} +Vec2 Vec2::operator + ( const Vec2 rhs ) const { return Vec2( this->x + rhs.x, this->y + rhs.y ); } +Vec2 Vec2::operator - ( const Vec2 rhs ) const { return Vec2( this->x - rhs.x, this->y - rhs.y ); } +Vec2 Vec2::operator * ( const Vec2 rhs ) const { return Vec2( this->x * rhs.x, this->y * rhs.y ); } +Vec2 Vec2::operator * ( const float scale ) const { return Vec2( this->x * scale, this->y * scale ); } +void Vec2::operator += ( const Vec2 & rhs ) { this->x += rhs.x; this->y += rhs.y; } +void Vec2::operator -= ( const Vec2 & rhs ) { this->x -= rhs.x; this->y -= rhs.y; } +void Vec2::operator *= ( const Vec2 & rhs ) { this->x *= rhs.x; this->y *= rhs.y; } +void Vec2::operator *= ( const float scale ) { this->x *= scale; this->y *= scale; } + +float Vec2::length() + { return sqrtf( this->x*this->x + this->y*this->y ); } +void Vec2::normalise() +{ + float mag = this->length(); + this->x /= mag; + this->y /= mag; +}