diff options
author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-09-25 13:07:13 +0200 |
---|---|---|
committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-09-25 13:07:13 +0200 |
commit | 35224c07549448e919a18a463e5dec81bbabf7c6 (patch) | |
tree | 6c9dea5b449625b057511f7f052842ab3cd1d7e8 /resource-manager/main.cpp | |
parent | 765485ced528ca2f4cf644a1503b9446c5826731 (diff) |
spritesheet and image changed
Diffstat (limited to 'resource-manager/main.cpp')
-rw-r--r-- | resource-manager/main.cpp | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/resource-manager/main.cpp b/resource-manager/main.cpp index 6dc362b..dc087c6 100644 --- a/resource-manager/main.cpp +++ b/resource-manager/main.cpp @@ -15,10 +15,6 @@ int main() { SDL_Init(SDL_INIT_VIDEO); - ResourceManager * rm = new ResourceManager; - - //Image* img = rm->Load<Image>("../spritesheet_test.png"); - //Resource* sound = rm->Load("/sound.ogg"); bool quit = false; @@ -28,18 +24,20 @@ int main() { = SDL_CreateWindow("Tessting resources", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, 0); + SDL_Renderer * renderer = SDL_CreateRenderer(window, -1, 0); - SpriteSheet spritesheet("../spritesheet_test.png", *renderer, 1, 4); + ResourceManager * rm = new ResourceManager(); + + Texture* img = rm->Load<Texture>("../img.png"); + img->setTexture(*renderer); + + SpriteSheet* SS = rm->Load<SpriteSheet>("../spritesheet_test.png"); + SDL_SetRenderDrawColor(renderer, 168, 230, 255, 255); SDL_RenderClear(renderer); while (!quit) { - Uint32 ticks = SDL_GetTicks(); - int sprite = (ticks / 100) % 4; - - //SDL_Rect srcrect = { sprite * 32, 0, 32, 64 }; - SDL_Rect dstrect = {10, 10, 32, 64}; while (SDL_PollEvent(&event) != NULL) { switch (event.type) { @@ -49,9 +47,9 @@ int main() { } } + SDL_RenderClear(renderer); - spritesheet.select_sprite(sprite, 0); - spritesheet.draw_selected_sprite(renderer, &dstrect); + SDL_RenderCopy(renderer, img->getTexture(), NULL, NULL); SDL_RenderPresent(renderer); } SDL_DestroyRenderer(renderer); |