diff --git a/main.cpp b/main.cpp index c132253..e34b4a0 100644 --- a/main.cpp +++ b/main.cpp @@ -7,6 +7,7 @@ #include "stuff/globals/globals.h" #include "stuff/callbacks/callbacks.h" +#include "stuff/objects/square.h" int main(int argc, char** argv) { @@ -16,14 +17,15 @@ int main(int argc, char** argv) SDL_Init(SDL_INIT_VIDEO); window = SDL_CreateWindow("threedee", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 1280, 720, SDL_WINDOW_SHOWN); surface = SDL_GetWindowSurface(window); - SDL_Event eventHandler; + global::entList.push_back(square(200, 200, 50, 50)); + while (global::running) { callbacks::handleCallbacks(&eventHandler); - SDL_Rect cursor{ global::mousePos.x, global::mousePos.y, 5, 5 }; - SDL_FillRect(surface, &cursor, SDL_MapRGB(surface->format, 0xFF, 0xFF, 0xFF)); + + global::entList.run(surface); SDL_UpdateWindowSurface(window); SDL_Delay(1); diff --git a/stuff/globals/globals.cpp b/stuff/globals/globals.cpp index 39e0e16..310e696 100644 --- a/stuff/globals/globals.cpp +++ b/stuff/globals/globals.cpp @@ -1,4 +1,5 @@ #include "globals.h" bool global::running = true; -vector2 global::mousePos; \ No newline at end of file +vector2 global::mousePos; +entityList global::entList; \ No newline at end of file diff --git a/stuff/globals/globals.h b/stuff/globals/globals.h index 5f23df0..85e4abe 100644 --- a/stuff/globals/globals.h +++ b/stuff/globals/globals.h @@ -1,7 +1,9 @@ #pragma once #include "../objects/vector.h" +#include "../objects/entityList.h" namespace global { extern bool running; extern vector2 mousePos; + extern entityList entList; } \ No newline at end of file diff --git a/stuff/objects/entityList.h b/stuff/objects/entityList.h new file mode 100644 index 0000000..67784e4 --- /dev/null +++ b/stuff/objects/entityList.h @@ -0,0 +1,17 @@ +#pragma once +#include +#include "SDL.h" + +#include "square.h" + +class entityList : public std::vector +{ +public: + void run(SDL_Surface* surface) + { + for (square entity : *this) + { + entity.run(surface); + } + } +}; \ No newline at end of file diff --git a/stuff/objects/square.h b/stuff/objects/square.h new file mode 100644 index 0000000..2e4d823 --- /dev/null +++ b/stuff/objects/square.h @@ -0,0 +1,25 @@ +#pragma once +#include "SDL.h" + +struct square +{ + SDL_Rect rect; + square() + { + rect.x = 0; + rect.y = 0; + rect.w = 0; + rect.h = 0; + } + square(int x_, int y_, int w_, int h_) + { + rect.x = x_; + rect.y = y_; + rect.w = w_; + rect.h = h_; + } + void run(SDL_Surface* surface) + { + SDL_FillRect(surface, &this->rect, SDL_MapRGB(surface->format, 0xFF, 0xFF, 0xFF)); + } +}; \ No newline at end of file diff --git a/threedee.vcxproj b/threedee.vcxproj index 6da5674..766c9ed 100644 --- a/threedee.vcxproj +++ b/threedee.vcxproj @@ -242,6 +242,8 @@ + + diff --git a/threedee.vcxproj.filters b/threedee.vcxproj.filters index 51eca80..54f1810 100644 --- a/threedee.vcxproj.filters +++ b/threedee.vcxproj.filters @@ -285,6 +285,12 @@ Header Files + + Header Files + + + Header Files +