May 21, 2013 at 1:55am UTC
I would like to know how to create an array of sdl surfaces. I've heard that its possible, but I'm not quite sure how. I think it involves something like this:
Sdl_surface *arrayname[2];
Sdl_surface *surface1;
Sdl_surface *surface2;
Surface1 = sdl_loadbmp("surface1");
Surface2 = sdl_loadbmp("surface2");
Sdl_blitsurface(arrayname[1], NULL, screen, NULL);
Sdl_blitsurface(arrayname[2], NULL, screen, NULL);
However it doesn't seem to work. Any explanations or alternate methods?
May 21, 2013 at 2:07am UTC
1 2 3 4 5 6 7
SDL_Surface* surfaces[ 2 ];
surfaces[ 0 ] = SDL_LoadBMP( "surface1.bmp" );
surfaces[ 1 ] = SDL_LoadBMP( "surface2.bmp" );
SDL_BlitSurface( surfaces[ 0 ], NULL, screen, NULL );
SDL_BlitSurface( surfaces[ 1 ], NULL, screen, NULL );
EDIT: btw don't forget to cleanup:
1 2
SDL_FreeSurface( surfaces[ 0 ] );
SDL_FreeSurface( surfaces[ 1 ] );
Last edited on May 21, 2013 at 10:00am UTC