Page 1 of 1

strcmp and getactor questions

PostPosted: Tue Jul 07, 2009 12:23 am
by zygoth
What, if anything, is wrong with this line of code?

if( strcmp(getactor(i, j), "thing") ==1)
do stuff;

also, does getactor only call the one pixel that an actor is technically on, or does it call any pixel it is shown on? If it is the first, how can I call the name of an actor who is showing on a set pixel? Something like GetAllActorsInCollisionWithPixel(x,y). I am trying to make a lighting effect with a canvas and I need to be able to tell if an actor is occupying a certain pixel. Also, is there anything like GetPixel(x,y) that returns the rgb values for a pixel? Thanks for any help.

Zygo

Re: strcmp and getactor questions

PostPosted: Tue Jul 07, 2009 1:01 am
by makslane
The getactor function returns the actors thats contains the given coordinate.
The funtion returns an actor pointer, not the name of the actor, so, you must use:

Code: Select all
if( strcmp(getactor(i, j)->name, "thing") ==0)
do stuff if the actor is "thing";

Re: strcmp and getactor questions

PostPosted: Tue Jul 07, 2009 2:04 am
by skydereign
The strcmp has to equal zero, as that is how strcmp works. It does not return true false type values, so what makslane has is right, in case you were wondering. It returns greater than 0 if the first string is greater than the second, 0 if they are the same, and less than 0 if the first is smaller than the second. The actual value being the difference.

Re: strcmp and getactor questions

PostPosted: Tue Jul 07, 2009 1:03 pm
by zygoth
Thanks a lot, I am going to go try it now.

So strcmp doesn't actually compare the strings, it only compares their length?

Zygo

Re: strcmp and getactor questions

PostPosted: Tue Jul 07, 2009 1:44 pm
by makslane

Re: strcmp and getactor questions

PostPosted: Tue Jul 07, 2009 2:55 pm
by zygoth
What does it mean for a character to have a higher value than another character?

Re: strcmp and getactor questions

PostPosted: Tue Jul 07, 2009 3:25 pm
by makslane
Means: D > A and X < Z

Re: strcmp and getactor questions

PostPosted: Tue Jul 07, 2009 6:50 pm
by zygoth
ok, thanks.