Use Mix_FreeChunk(ed_swish); instead free();
Some ideas: // toggle screen change off
sceneChange = FALSE;
// make sure the i variable is clean
i=0;
src.w = TILESIZE;
src.h = TILESIZE;
dest.w = 800;
dest.h = 480;
for(y=2; y < 12; y++) {
for(x=0; x < 20; x++) {
dest.x = x*TILESIZE;
dest.y = y*TILESIZE;
switch(scene[i]) {
// grass
case 'g':
src.x = 0;
src.y = 0;
sceneChange = TRUE;
break;
.....
case 'k': // dead desert tree
src.x = 740;
src.y = 80;
sceneBlock[x][y]=TRUE; // dynamically add the collision
sceneChange = TRUE;
break;
default:
break;
}
i++;
if (sceneChange) {
SDL_BlitSurface(temp2, &src, sceneSurface, &dest);
sceneChange = FALSE;
}
}