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 / Displaying parameters on screen

Author
Message
Jigzy
13
Years of Service
User Offline
Joined: 30th Aug 2011
Location:
Posted: 31st Aug 2011 00:02
Hello,

I`m working on a 2D game and I was wondering if it`s possible to display a parameter on game screen. I need to display bool parameter to see if everything is checking right.

In std c++ it was something like this: cout << x;

Thanks in advance.
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 31st Aug 2011 08:18 Edited at: 31st Aug 2011 20:03
Use sprintf to make a formatted string out of your parameters.

http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/

Booleans can be displayed as integers (%d) and will appear as 1 or 0 for true/false, which is quite enough for debug purposes:



Or if you want to get a bit more sophisticated, you can convert it to text:



You can display several parameters in one string.
Jigzy
13
Years of Service
User Offline
Joined: 30th Aug 2011
Location:
Posted: 31st Aug 2011 11:38
Well I tried something like this:



And it displayed error message :

error C2664: 'dbText' : cannot convert parameter 3 from 'int' to 'char *'
1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 31st Aug 2011 15:34
sprintf(Buffer, "valid is: %d", int(valid));

The fastest code is the code never written.
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: &lt;script&gt; alert(1); &lt;/script&gt;
Posted: 31st Aug 2011 16:37 Edited at: 31st Aug 2011 16:38
Buffer char[255];
did you mean
char Buffer[255];

i have never seen such syntax

Jigzy
13
Years of Service
User Offline
Joined: 30th Aug 2011
Location:
Posted: 31st Aug 2011 17:06
That was is, didn`t notice the mistake. Thanks.
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 31st Aug 2011 20:02
Yes, I'm sorry, typing mistake! It should be char Buffer[255];
newfavo
User Banned
Posted: 7th Sep 2011 07:17
I am trying to fade my background onto the screen over a duration of 2 seconds. The code I'm using (below) just makes the bitmap instantly appear fully visible, but I fail to see why. Hopefully you guys will know what my problem is.

_________________
design of business cards

Login to post a reply

Server time is: 2024-11-19 08:43:17
Your offset time is: 2024-11-19 08:43:17