I am a little confused as to why this happens in what I have been working on.
if( game_debug == true ) {
render_var( 16, 184, TEXT_LEFT, "FPS:", (int)framespersecond, true );
render_var( 16, 16, TEXT_LEFT, "CAMERA X:", (int)camera_x, true );
render_var( 16, 32, TEXT_LEFT, "CAMERA Y:", (int)camera_y, true );
if( lvl_name != NULL ) {
render_text( 320 - 16, 16, TEXT_RIGHT, "LEVEL: ", true );
render_text( 320 - 16, 32, TEXT_RIGHT, lvl_name, true );
}
} else {
render_text( 320 - 16, 16, TEXT_RIGHT, "F1: View Debug Info", true );
}
when I call upon change_level
int change_level( const char* filename ) {
/* clear any current level assets */
/* level information */
lvl_name = "";
...
/* camera coordinates */
camera_x = 0;
camera_y = 0;
/* tiles */
...
/* objects */
/* parse new level */
parse_level( filename );
/* tell user level has been changed */
printf( "level has been changed to: %s\n", lvl_name );
}
while game_debug is currently true, the game will crash. However, if I comment out the first three parts (rendering the framespersecond, camera_x, and camera_y) then the crash does not occur. The crash does not occur either if I put game_debug = false; somewhere within the change_level() function. Another weird thing (this is where the thread title comes in) is the game does not crash if I am currently printing something over and over again, so I could put printf("printing!\n"); above the line of code that renders framespersecond, and when I change levels (game_debug is not set to false in this instance), the crash does not occur.
Do you have any ideas as to why this anomaly happens? Thanks