sdl: mehrere bilder auf eine oberfläche laden?
-
void drawBlocks() { for(int i = 0; i<32; i++) { for(int j = 0; j<20; j++) { if(fieldArray[i][j] == 1) { loadimg(gBlocks,iconArray,i*25,j*25,"block.bmp",25,25); } } } }hiermit lade ich 30 "block.bmp"'s auf die oberfläche SDL_Surface *gBlocks;
hier die loadimg funktionvoid loadimg(SDL_Surface *gSurf, int array[SWIDTH][SHEIGHT],int x, int y, char *path, int width, int height) { SDL_Surface *temp = SDL_LoadBMP(path); gSurf = SDL_ConvertSurface(temp, screen->format, SDL_SWSURFACE); SDL_FreeSurface(temp); // Lock surface if needed if (SDL_MUSTLOCK(gSurf)) if (SDL_LockSurface(gSurf)< 0) return; int i, j; for (i = 0; i < height; i++) { for (j = 0; j < width; j++) { int tileofs = j+(i*width); array[j][i] = ((unsigned int*)gSurf->pixels)[tileofs]; //((unsigned int*)screen->pixels)[screenofs] = ((unsigned int*)gSurf->pixels)[tileofs]; tileofs++; } }ich bekomme aber immernur einen block auf position 0,0!
warum? vielen dank!edit fehler gefunden (ich depp ^^)
-
übrigens kriegst du speicherlöscher weil du immer neue Surfaces erstellst (mit SDL_ConvertSurface()). Falls das nicht zu deinem gefundenen Fehler gehört...
geloescht