Page 2 of 2

Re: String help?

Posted: Sat Mar 14, 2009 9:58 am
by ibly31
MarauderIIC wrote: And it's not STD::string. It's std::string.
I was typing it on my iPod Touch, and it thinks i was talking about Sexually Transmitted Diseases, and obviously I would have figured it out, the compiler might have even fixed it as i was typing it :D

Re: String help?

Posted: Sat Mar 14, 2009 4:44 pm
by MarauderIIC
Haha, alright.

Also, I've used the console with SDL applications (on accident). My checkers program actually took cin and cout and updated the separate SDL window (it was originally a console app and I just changed main() to have argc and argv and built it with SDL).

Re: String help?

Posted: Sat Mar 14, 2009 4:49 pm
by programmerinprogress
Really? well I can't get it to work, and i've done some googling, and apparently this problem is quite common, and i've tried the majority of the remedies suggested (with the exception of the ones that want me to recompile SDL), most of them state that SDL 'redirects' streams to output files.

Re: String help?

Posted: Sat Mar 14, 2009 4:53 pm
by ibly31
I packaged a nice little function, its called addInt(std::string, int num)

and you'd call it by this

std::string asfd = addInt("Value = ",value);

draw asdf...

Re: String help?

Posted: Sat Mar 14, 2009 5:30 pm
by Scoody
ibly31 wrote:I don't wanna make a whole new string and a new header... Then there'd be the problem of concertng that back to a STD::string and them to a c_str()
Actually, mystringstream.str() is the converted string-version and mystringstream.str().c_str() for the C-string. But since that's not what you wanted to do I won't delve deeper.

Re: String help?

Posted: Sat Mar 14, 2009 8:30 pm
by ibly31
Yeah, lol i ended up using stringstream anyway.

I have a question on Keystates, they arent working... whats wrong with this code?

Code: Select all

		Uint8 *keystates = SDL_GetKeyState(NULL);
		
		if(keystates[SDLK_UP])
			charY -= speedX;
		
		if(keystates[SDLK_DOWN])
			charY += speedY;
		
		if(keystates[SDLK_LEFT])
			charX -= speedX;
		
		if(keystates[SDLK_RIGHT])
			charX += speedX;
			  
		if(keystates[SDLK_ESCAPE])
			quit = true;
			  

Re: String help?

Posted: Sat Mar 14, 2009 11:54 pm
by Ginto8
It looks fine... Could you tell us what's happening wrong?

Re: String help?

Posted: Sun Mar 15, 2009 10:30 am
by ibly31
I fixed it, the main while(quit == false) loop didn't have another while(pollevent) loop inside it.