EDN Admin
Well-known member
void scene::sceneplay( string text_file_name )
{
//Render the text
string line;
ifstream myfile ( text_file_name.c_str() );
if ( myfile.is_open() && rendered_text == false )
{
while ( myfile.good() )
{
for( i = 0; i < 12 ; i++ )
{
getline (myfile,line);
message = TTF_RenderText_Solid( font, line.c_str(), textColor );
cout << line << endl;
}
}
rendered_text = true;
myfile.close();
}
else
{
cout << "Unable to open file" << endl;
}
for(i = 0; i < 12; i++ )
{
apply_surface( 16, 16 + (16*i), message, screen, NULL );
}
}
That is all the code you need to see because that is all the code I have in my program correlating to loading stuff from a .txt file, though it is activated here at the end
void scene::sequence()
{
//this is so it can call up the text renderer
scene scene;
//render the background first so it is behind the text
if( background_change == true )
{
apply_surface( 0, 0, background, screen, NULL );
background_change = false;
}
//render the text
if( sequence_change == true )//when the sequence change occurs, it will re-render the text
{
scene.sceneplay("text.txt");
sequence_change = false; //after it has done so, the sequence change will be over
}
}
Here is what I need help with; at the moment, there are only 12 lines in my .txt fileThis is the text being rendered on screen
Line 2
Line 3
Line 4
Line 5
Line 6
Line 7
Line 8
Line 9
Line 10
Line 11
Line 12
I know I only have 12 arrays in message right now, however I can change that later. I would like to be able to set up my text file like soBACK = "background.png"; SONG = "song.mp3"; LEVEL = "level.lvl"; END; etc;
This is the text being rendered on screen
Line 2
Line 3
Line 4
Line 5
Line 6
Line 7
Line 8
Line 9
Line 10
Line 11
Line 12
and after you see Line 12, you will see another set of information like "BACK" and "SONG" again. If that is too complex, then will this be better?BACK = "background.png"
SONG = "song.mp3";
This is the text being rendered on screen
Line 2
Line 3
Line 4
Line 5
Line 6
Line 7
Line 8
Line 9
Line 10
Line 11
Line 12
LEVEL = "level.lvl";
END;
I just dont know how to incorporate this kinda stuff, and I cant find the tutorials. Thanks
View the full article
{
//Render the text
string line;
ifstream myfile ( text_file_name.c_str() );
if ( myfile.is_open() && rendered_text == false )
{
while ( myfile.good() )
{
for( i = 0; i < 12 ; i++ )
{
getline (myfile,line);
message = TTF_RenderText_Solid( font, line.c_str(), textColor );
cout << line << endl;
}
}
rendered_text = true;
myfile.close();
}
else
{
cout << "Unable to open file" << endl;
}
for(i = 0; i < 12; i++ )
{
apply_surface( 16, 16 + (16*i), message, screen, NULL );
}
}
That is all the code you need to see because that is all the code I have in my program correlating to loading stuff from a .txt file, though it is activated here at the end
void scene::sequence()
{
//this is so it can call up the text renderer
scene scene;
//render the background first so it is behind the text
if( background_change == true )
{
apply_surface( 0, 0, background, screen, NULL );
background_change = false;
}
//render the text
if( sequence_change == true )//when the sequence change occurs, it will re-render the text
{
scene.sceneplay("text.txt");
sequence_change = false; //after it has done so, the sequence change will be over
}
}
Here is what I need help with; at the moment, there are only 12 lines in my .txt fileThis is the text being rendered on screen
Line 2
Line 3
Line 4
Line 5
Line 6
Line 7
Line 8
Line 9
Line 10
Line 11
Line 12
I know I only have 12 arrays in message right now, however I can change that later. I would like to be able to set up my text file like soBACK = "background.png"; SONG = "song.mp3"; LEVEL = "level.lvl"; END; etc;
This is the text being rendered on screen
Line 2
Line 3
Line 4
Line 5
Line 6
Line 7
Line 8
Line 9
Line 10
Line 11
Line 12
and after you see Line 12, you will see another set of information like "BACK" and "SONG" again. If that is too complex, then will this be better?BACK = "background.png"
SONG = "song.mp3";
This is the text being rendered on screen
Line 2
Line 3
Line 4
Line 5
Line 6
Line 7
Line 8
Line 9
Line 10
Line 11
Line 12
LEVEL = "level.lvl";
END;
I just dont know how to incorporate this kinda stuff, and I cant find the tutorials. Thanks
View the full article