Using SDL2 in C++ I can load textures with out problem however, I have sprites that are from about 15 different png's that I was hoping I could load them all up and for loop through them. However, when I try this it looks like the image is still .
I am hoping that I wouldn’t have to photo shop them into one image and shift/pan through that considering I have about 3K of images to go through.
can some one provide an example of how this could be done cleanly?
I have been working on this for a while for a bit and yes, this is probably a coding mistake as I am learning C++ still and know that for me to learn is to take up a project.
int main ( int argc, char *argv[] )
{
SDL_Init(SDL_INIT_EVERYTHING);
Window = SDL_CreateWindow("NEW WINDOW",100,100,300,300,SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
renderer = SDL_CreateRenderer(Window,-1,SDL_RENDERER_ACCELERATED);
if (Window == NULL)
{
std::cout << "Window Couldn't be Created!\n";
}
struct imagebatch
{
const char *image;
};
imagebatch foto;
// A for loop is needed here to loop through Healer0.png Healer1.png to Healer15.png
foto.image = "DData/towners/healer/healer/Healer0.png";
HealerTexture = IMG_LoadTexture(renderer,foto.image);
//loads an image;
//HealerTexture = IMG_LoadTexture(renderer,"DData/towners/healer/healer/Healer0.png");
//defines the rect of this image;
SDL_Rect HealerRect;
HealerRect.x = 0;
HealerRect.y = 0;
HealerRect.w = 90;
HealerRect.h = 90;
while (!quit)
{
while( SDL_PollEvent( &event ) != 0 )
{
//User requests quit
if( event.type == SDL_QUIT )
{
quit = true;
}
}
SDL_RenderClear(renderer);
//Blit everything here.
SDL_RenderCopy(renderer,HealerTexture,NULL,&HealerRect);
SDL_RenderPresent(renderer);
}
close();
return 0;
}
Full code is here: http://pastebin.com/H5fD6cfX
SDL_Textures
and then switch the array index of the surface you're drawing with the one you currently want to show. If that doesn't make sense, I can write a full answer. \$\endgroup\$