Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Simple C++ Error Im sure

Author
Message
Swampert
15
Years of Service
User Offline
Joined: 17th Dec 2008
Location: Somewhere in the Interwebs
Posted: 27th Jan 2009 03:46
srry im a little dizzy today so i think im losing it lol.

im trying to combine a dbText string (third param) with an integer so it will display the camera location

"The Current Camera Location is " + camx + camy + camz (type thing)

I know im using + like addition so its not working correctly. Thanks for the help mates

GDA - Game Developers Anonymous - Get in touch with your creative side.

Yeah I like Pokemon... so what?
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 27th Jan 2009 04:01
The parameter says that it takes a pointer to a character or character string.



Or something like that. Just don't reuse the buffer in the same operation.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 27th Jan 2009 04:02
String concatenation isn't an easy thing to do in C++ like it is in BASIC.

I've also tried to do this and what I ended up doing was create a temporary character pointer array, concatenating the necessary information onto it and then passing that into the dbText function. Not fun... so since it was just for debugging, I didn't spend a lot of time on it and just went with having the values on individual lines.


The one and only,


Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 27th Jan 2009 05:06 Edited at: 30th Jan 2009 00:33
#include <string>

std::string tmp = "Camera: ";
tmp += camx; tmp += ", "; tmp += camy; tmp += ", "; tmp += camz;
dbText(x, y, (char *)tmp.c_str());

If you get problems, remove the (char *) in the call to dbText.
Swampert
15
Years of Service
User Offline
Joined: 17th Dec 2008
Location: Somewhere in the Interwebs
Posted: 28th Jan 2009 03:52
alright i see thx mate

GDA - Game Developers Anonymous - Get in touch with your creative side.

Yeah I like Pokemon... so what?
Orac
18
Years of Service
User Offline
Joined: 16th May 2006
Location: Billingham
Posted: 28th Jan 2009 09:41
This is how I usually do it ..



Use %d for integers or %f for floats.

Of all the things I've lost .. I miss my marbles most of all.
Swampert
15
Years of Service
User Offline
Joined: 17th Dec 2008
Location: Somewhere in the Interwebs
Posted: 28th Jan 2009 23:38
i got 3 linker errors from main.obj like


what do i do?

GDA - Game Developers Anonymous - Get in touch with your creative side.

Yeah I like Pokemon... so what?
Orac
18
Years of Service
User Offline
Joined: 16th May 2006
Location: Billingham
Posted: 29th Jan 2009 10:15
Hmm. I don't think those errors are coming from the code I posted, if you are using it exactly as shown. Using sprintf() in this way is pretty standard 'C' coding. Are you sure the buffer you are allocating is big enough to hold the entire string? Are you using the correct variable types to match up with the format specifiers (%d for integers, %f for floating point etc.)

Of all the things I've lost .. I miss my marbles most of all.
Swampert
15
Years of Service
User Offline
Joined: 17th Dec 2008
Location: Somewhere in the Interwebs
Posted: 30th Jan 2009 00:10
I'll try using float but i still get the same errors. the sprintf() is fine but i'm using C++

GDA - Game Developers Anonymous - Get in touch with your creative side.

Yeah I like Pokemon... so what?
puppyofkosh
17
Years of Service
User Offline
Joined: 9th Jan 2007
Location:
Posted: 30th Jan 2009 01:20
I use this

ionstream
20
Years of Service
User Offline
Joined: 4th Jul 2004
Location: Overweb
Posted: 30th Jan 2009 06:02
If you're familiar with cout then you may find that stringstreams are a bit easier to use:



Streams are fun!

Swampert
15
Years of Service
User Offline
Joined: 17th Dec 2008
Location: Somewhere in the Interwebs
Posted: 30th Jan 2009 12:02 Edited at: 31st Jan 2009 05:41
I like that answer lol. Much more basic with just << operators xD

EDIT:: Got it working with Orac's pBuf. Thanks for your help mates

GDA - Game Developers Anonymous - Get in touch with your creative side.

Yeah I like Pokemon... so what?

Login to post a reply

Server time is: 2024-11-25 13:23:33
Your offset time is: 2024-11-25 13:23:33