sprintf(text, "%d", x) always gives 0

Non-platform specific questions.

sprintf(text, "%d", x) always gives 0

Postby akr » Wed Mar 17, 2010 9:57 am

Hi,

Why do I always get 0 in text? What is the best way to compare the x and y coordinate of an actor with screen boundaries?

Andreas
Co-Developer of GE engine

If u are interrested in new features of apple or android ge engines check the engine support website game-editor.net regulary.
akr
 
Posts: 453
Joined: Thu Feb 25, 2010 7:56 pm
Location: Germany, Ulm
Score: 40 Give a positive score

Re: sprintf(text, "%d", x) always gives 0

Postby makslane » Wed Mar 17, 2010 12:20 pm

x is an float variable.
So, use:

Code: Select all
sprintf(text, "%f", x);


Or:

Code: Select all
textNumber = x;


What is the best way to compare the x and y coordinate of an actor with screen boundaries?


You can compare the xscreen and yscreen of the actor with the width and height of the view.
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Re: sprintf(text, "%d", x) always gives 0

Postby Bee-Ant » Wed Mar 17, 2010 4:50 pm

akr wrote:Hi,

Why do I always get 0 in text? What is the best way to compare the x and y coordinate of an actor with screen boundaries?

Andreas

Hmm...did you want to check some actor x and y coordinate by displaying their values on screen?
Code: Select all
int i=actor.x;
int j=actor.y;
sprintf(text,"%i,%i",i,j);

You can't just add them directly.
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: sprintf(text, "%d", x) always gives 0

Postby akr » Thu Mar 18, 2010 8:39 am

%i will not work. It is a float. Will use %f like maks mentioned.

Whats the reason for x to be float? As far as i know xmouse is integer. I am confused. Is there a document where I can find the types?

Andreas
Co-Developer of GE engine

If u are interrested in new features of apple or android ge engines check the engine support website game-editor.net regulary.
akr
 
Posts: 453
Joined: Thu Feb 25, 2010 7:56 pm
Location: Germany, Ulm
Score: 40 Give a positive score

Re: sprintf(text, "%d", x) always gives 0

Postby makslane » Thu Mar 18, 2010 1:36 pm

Whats the reason for x to be float? As far as i know xmouse is integer.


In the fisrt GAme Editor versions the x and y was integer.
But some games need screpts like " x += 0.5;". So x and y are promoted to double vars.
The xmouse and ymouse keep integer (the mouse always returns integer coordinates).

I am confused. Is there a document where I can find the types?


Only in the code:
http://code.game-editor.com/browser/tru ... ne/Actor.h (struct stActorVars)
http://code.game-editor.com/browser/tru ... e/Script.h

Script reference:
http://game-editor.com/docs/script_reference.htm
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest