This is really frustrating[Solved][SDL_SurfaceVectors]
Posted: Mon Jul 30, 2012 6:08 pm
I'm trying to create a vector of SDL surface's, but for everything I try fails. Maybe its just not possible and I have to use some other kind of container, IDK.
Here's the most relevant part of my code:
Its a slightly modified tutorial function.
These are my errors:
I just do not know how to read these massive statements, like the one in bold there. If I did it might help me. But other things like a function argument list, which pops up an intellisense thingamjigger which shows what its supposed to be, I find impossible to comprehend!
Is there a way to make a potentially infinite list of surfaces? I know that would create more overhead with every new surface, but I just need to make a few. This function is supposed to take input from the user, display it in the window, and once return is pressed, move the message and any others away from the box, and upward. I know of no other way to make multiple lines of text in a surface other than to make more surfaces!
Im
Here's the most relevant part of my code:
Its a slightly modified tutorial function.
Code: Select all
void handle_input() {
if (event.type == SDL_KEYDOWN) {
std::string temp = str;
if ( str.length() <= 64) {
logFile << "str's length is <= 64.\n";
if ( event.key.keysym.unicode == (Uint16) ' ' ) {
str += (char)event.key.keysym.unicode;
logFile << "Space bar was pressed.\n";
}
else if ( ( event.key.keysym.unicode >= (Uint16)'0') && (event.key.keysym.unicode <= (Uint16) '9' ) ) //Finally works!
{
str += (char)event.key.keysym.unicode;
logFile << "Number key: " <<(char)event.key.keysym.unicode << " pressed, and added to str.\n";
}
else if (( event.key.keysym.unicode >= (Uint16)'A' )&& (event.key.keysym.unicode <= (Uint16) 'Z') )
{
str += (char)event.key.keysym.unicode;
logFile << "Number key: " <<(char)event.key.keysym.unicode << " pressed, and added to str.\n";
}
else if ( (event.key.keysym.unicode >= (Uint16)'a' )&& (event.key.keysym.unicode <= (Uint16) 'z' ) )
{
str += (char)event.key.keysym.unicode;
logFile << "Number key: " <<(char)event.key.keysym.unicode << " pressed, and added to str.\n";
}
else if ( (event.key.keysym.unicode == SDLK_RETURN ) )
{
str = " RETURN WAS PRESSED.";
//I am going to need to render multiple surfaces for each message, and two extra for the input window. This may need to be a vector of SDL_Surface's, and include two SDL_Rect's for both the body of messages, and the input box. The body will simply iterate through the SDL_Surface's, altering the SDL_Rect by 13 for every one, making them all move at the same time, then resetting the rect's Y value to the top position of the body.
}
if (event.key.keysym.unicode == SDLK_BACKSPACE && str.length() != 0) {
str.erase(str.length() - 1);
logFile << "Backspace was pressed.\n";
}
if (str != temp) {
SDL_FreeSurface ( text );
text = TTF_RenderText_Solid(font, str.c_str(), textcolor); //Assigns the rendered text to the end of the suface_vect, vector..
surface_vect->push_back (& text );
logFile << "Full text rendered to SDL_Surface text: " << str.c_str() << "\n";
}
}
}
On a side note,1>------ Build started: Project: KeypressSDL, Configuration: Debug Win32 ------
1> NetworkingWithSDLExperiment.cpp
1>NetworkingWithSDLExperiment.cpp(119): error C2228: left of '.push_back' must have class/struct/union
1>------ Build started: Project: KeypressSDL, Configuration: Debug Win32 ------
1> NetworkingWithSDLExperiment.cpp
1>NetworkingWithSDLExperiment.cpp(119): error C2228: left of '.push_back' must have class/struct/union
1> type is 'std::vector<_Ty> *[1]'
1> with
1> [
1> _Ty=SDL_Surface
1> ]
1>NetworkingWithSDLExperiment.cpp(376): error C2065: 'vertCoord' : undeclared identifier //Ignore this.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I just do not know how to read these massive statements, like the one in bold there. If I did it might help me. But other things like a function argument list, which pops up an intellisense thingamjigger which shows what its supposed to be, I find impossible to comprehend!
Is there a way to make a potentially infinite list of surfaces? I know that would create more overhead with every new surface, but I just need to make a few. This function is supposed to take input from the user, display it in the window, and once return is pressed, move the message and any others away from the box, and upward. I know of no other way to make multiple lines of text in a surface other than to make more surfaces!
Im