aboutsummaryrefslogtreecommitdiff
path: root/mwe/resource-manager/main.cpp
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-10-25 20:59:34 +0200
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-10-25 20:59:34 +0200
commit15a4c4a1cf67e13be53ef423c51c56488f332ea9 (patch)
tree661084fc8171089ce32bf779f2b3a85d634b38e4 /mwe/resource-manager/main.cpp
parentf472e0ba3bf54fc5055cf9f08925bed3f98a1dbc (diff)
parentb3b762a34e7ccb4a0dcd041a693ac7180af16002 (diff)
merge conficts fixed
Diffstat (limited to 'mwe/resource-manager/main.cpp')
-rw-r--r--mwe/resource-manager/main.cpp77
1 files changed, 77 insertions, 0 deletions
diff --git a/mwe/resource-manager/main.cpp b/mwe/resource-manager/main.cpp
new file mode 100644
index 0000000..b6416f6
--- /dev/null
+++ b/mwe/resource-manager/main.cpp
@@ -0,0 +1,77 @@
+
+
+#include "Image_asset.h"
+#include "map_asset.h"
+#include "resource_converter.h"
+#include "resource_manager.h"
+#include "spritesheet.h"
+#include <SDL.h>
+#include <SDL2/SDL_image.h>
+#include <SDL_events.h>
+#include <SDL_rect.h>
+#include <SDL_render.h>
+#include <SDL_stdinc.h>
+#include <SDL_surface.h>
+#include <SDL_timer.h>
+#include <SDL_video.h>
+#include <cstddef>
+
+int main() {
+ SDL_Init(SDL_INIT_VIDEO);
+
+ bool quit = false;
+
+ SDL_Event event;
+
+ SDL_Window * window
+ = SDL_CreateWindow("Tessting resources", SDL_WINDOWPOS_UNDEFINED,
+ SDL_WINDOWPOS_UNDEFINED, 640, 480, 0);
+
+ SDL_Renderer * renderer = SDL_CreateRenderer(window, -1, 0);
+
+ ResourceManager * rm = ResourceManager::get_instance();
+ ResourceConverter resource_converter;
+
+ Texture * img = rm->Load<Texture>("../img.png");
+
+ SpriteSheet * SS = rm->Load<SpriteSheet>("../spritesheet_test.png");
+ Map * map = rm->Load<Map>("../../asset/tiled/demo.tmx");
+
+ SDL_Surface * surface = resource_converter.FromStringToImage(*img);
+ SDL_Texture * m_texture = SDL_CreateTextureFromSurface(renderer, surface);
+ SDL_FreeSurface(surface);
+
+ TiledMap testingTiledMap = resource_converter.FromStringToMap(*map);
+ testingTiledMap.SetRenderer(*renderer);
+
+ SDL_SetRenderDrawColor(renderer, 168, 230, 255, 255);
+ SDL_RenderClear(renderer);
+
+ while (!quit) {
+ Uint32 ticks = SDL_GetTicks();
+ int sprite = (ticks / 100) % 4;
+
+ while (SDL_PollEvent(&event) != NULL) {
+ switch (event.type) {
+ case SDL_QUIT:
+ quit = true;
+ break;
+ }
+ }
+
+ SDL_RenderClear(renderer);
+
+ SDL_RenderCopy(renderer, m_texture, NULL, NULL);
+ testingTiledMap.draw();
+
+ SDL_RenderPresent(renderer);
+ }
+ delete rm;
+
+ SDL_DestroyTexture(m_texture);
+ SDL_DestroyRenderer(renderer);
+ SDL_DestroyWindow(window);
+ SDL_Quit();
+
+ return 0;
+}