diff options
Diffstat (limited to 'resource-manager/main.cpp')
-rw-r--r-- | resource-manager/main.cpp | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/resource-manager/main.cpp b/resource-manager/main.cpp index a301114..6b3a23e 100644 --- a/resource-manager/main.cpp +++ b/resource-manager/main.cpp @@ -2,6 +2,7 @@ #include "Image_asset.h" #include "map_asset.h" +#include "resource_converter.h" #include "resource_manager.h" #include "spritesheet.h" #include <SDL.h> @@ -14,6 +15,8 @@ #include <SDL_timer.h> #include <SDL_video.h> #include <cstddef> +#include <iostream> +#include <ostream> int main() { SDL_Init(SDL_INIT_VIDEO); @@ -27,20 +30,25 @@ int main() { SDL_WINDOWPOS_UNDEFINED, 640, 480, 0); + SDL_Renderer * renderer = SDL_CreateRenderer(window, -1, 0); ResourceManager * rm = new ResourceManager(); + ResourceConverter resource_converter; Texture* img = rm->Load<Texture>("../img.png"); - img->setTexture(*renderer); SpriteSheet* SS = rm->Load<SpriteSheet>("../spritesheet_test.png"); - SS->set_spritesheet_data(*renderer, 1, 4); - Map* map = rm->Load<Map>("../../asset/tiled/demo.tmx"); - map->SetRenderer(*renderer); + + 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); @@ -55,19 +63,20 @@ int main() { quit = true; break; } - } + } SDL_RenderClear(renderer); - SDL_RenderCopy(renderer, img->getTexture(), NULL, NULL); - SS->select_sprite(sprite, 0); - SDL_Rect pos = {10,10,32,64}; - SS->draw_selected_sprite(renderer, &pos); - map->draw(); + + 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(); |