My project is now crashing every time I quit with memory access errors.
Here is the updated source with the additions that got my project to compile in the first place. (Thanks again BTW.)
https://github.com/quadcricket/legend-of-pandora/blob/master/source/common/source/main.c (https://github.com/quadcricket/legend-of-pandora/blob/master/source/common/source/main.c)
When I press 'Escape' to quit the game crashes with "CRT: unhandled exception".
I have narrowed it down to the SDL_Mixer library not freeing memory properly for the audio sample. If I comment out the audio section the project works fine.
I feel like I'm so close to getting this working properly. Thanks again for your time.
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;
}
}
That did it! Thank you so much TimoVJL!
Also thank you for the suggestion. That REALLY cleans things up.
It's odd thinking about how many times I've seen this code and never thought about how much space that part takes up.
You rock! I can now finally get back to what I want to do... learning C.
:D