diff --git a/main.cpp b/main.cpp index 0542846..df2b31c 100644 --- a/main.cpp +++ b/main.cpp @@ -3,7 +3,7 @@ #include "SDL.h" #include "stuff/objects/vector2.h" -#include "stuff/objects/vector.h" +#include "stuff/objects/vector3.h" #include "stuff/globals/globals.h" #include "stuff/callbacks/callbacks.h" diff --git a/stuff/globals/globals.cpp b/stuff/globals/globals.cpp index 310e696..ee16eff 100644 --- a/stuff/globals/globals.cpp +++ b/stuff/globals/globals.cpp @@ -2,4 +2,4 @@ bool global::running = true; vector2 global::mousePos; -entityList global::entList; \ No newline at end of file +entityList2D global::entList; \ No newline at end of file diff --git a/stuff/globals/globals.h b/stuff/globals/globals.h index 85e4abe..22c187b 100644 --- a/stuff/globals/globals.h +++ b/stuff/globals/globals.h @@ -1,9 +1,9 @@ #pragma once -#include "../objects/vector.h" -#include "../objects/entityList.h" +#include "../objects/vector3.h" +#include "../objects/entityList2D.h" namespace global { extern bool running; extern vector2 mousePos; - extern entityList entList; + extern entityList2D entList; } \ No newline at end of file diff --git a/stuff/objects/cube.h b/stuff/objects/cube.h new file mode 100644 index 0000000..a25ab4c --- /dev/null +++ b/stuff/objects/cube.h @@ -0,0 +1,22 @@ +#pragma once +#include "square.h" +/* +cubes are the basic 3D entity +*/ +struct cube : public square +{ + float z; + cube() : square() + { + this->z = 0; + } + cube(float x_, float y_, float z_, int radius_) : square(x_, y_, radius_) + { + this->z = z_; + } + void run(SDL_Surface* surface) + { + SDL_Rect rect{ this->x, this->y, this->radius, this->radius }; + SDL_FillRect(surface, &rect, SDL_MapRGB(surface->format, 0xFF, 0xFF, 0xFF)); + } +}; \ No newline at end of file diff --git a/stuff/objects/entityList.h b/stuff/objects/entityList2D.h similarity index 63% rename from stuff/objects/entityList.h rename to stuff/objects/entityList2D.h index 67784e4..0f6d623 100644 --- a/stuff/objects/entityList.h +++ b/stuff/objects/entityList2D.h @@ -3,8 +3,10 @@ #include "SDL.h" #include "square.h" - -class entityList : public std::vector +/* +entityList2D is the 2D entity container class +*/ +class entityList2D : public std::vector { public: void run(SDL_Surface* surface) diff --git a/stuff/objects/entityList3D.h b/stuff/objects/entityList3D.h new file mode 100644 index 0000000..168c59f --- /dev/null +++ b/stuff/objects/entityList3D.h @@ -0,0 +1,19 @@ +#pragma once +#include +#include "SDL.h" + +#include "cube.h" +/* +entityList3D is the 3D entity container class +*/ +class entityList3D : public std::vector +{ +public: + void run(SDL_Surface* surface) + { + for (cube entity : *this) + { + entity.run(surface); + } + } +}; \ No newline at end of file diff --git a/stuff/objects/square.h b/stuff/objects/square.h index fd09fc8..6d9e008 100644 --- a/stuff/objects/square.h +++ b/stuff/objects/square.h @@ -8,16 +8,12 @@ squares are the basic 2D entity struct square : public vector2 { int radius; - square() + square() : vector2() { - this->x = 0; - this->y = 0; this->radius = 0; } - square(int x_, int y_, int radius_) + square(float x_, float y_, int radius_) : vector2(x_, y_) { - this->x = x_; - this->y = y_; this->radius = radius_; } void run(SDL_Surface* surface) diff --git a/stuff/objects/vector.h b/stuff/objects/vector3.h similarity index 53% rename from stuff/objects/vector.h rename to stuff/objects/vector3.h index 303e4e6..6a53c60 100644 --- a/stuff/objects/vector.h +++ b/stuff/objects/vector3.h @@ -1,18 +1,18 @@ #pragma once #include "vector2.h" /* -vectors extend vector2s and hold 3D cartesian coordinates +vector3s extend vector2s and hold 3D cartesian coordinates */ -struct vector : public vector2 +struct vector3 : public vector2 { float z; - vector() + vector3() { this->x = 0.f; this->y = 0.f; this->z = 0.f; } - vector(float x_, float y_, float z_) + vector3(float x_, float y_, float z_) { this->x = x_; this->y = y_; diff --git a/threedee.vcxproj b/threedee.vcxproj index 766c9ed..9dfc5d1 100644 --- a/threedee.vcxproj +++ b/threedee.vcxproj @@ -241,11 +241,13 @@ + - + + - + diff --git a/threedee.vcxproj.filters b/threedee.vcxproj.filters index 54f1810..6d7f0a2 100644 --- a/threedee.vcxproj.filters +++ b/threedee.vcxproj.filters @@ -276,9 +276,6 @@ Header Files - - Header Files - Header Files @@ -288,7 +285,16 @@ Header Files - + + Header Files + + + Header Files + + + Header Files + + Header Files