strcmp and getactor questions

Non-platform specific questions.

strcmp and getactor questions

Postby zygoth » Tue Jul 07, 2009 12:23 am

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
Nova: 100% Vertigo/Mazeman: 100%
Visit my website to download them both! http://www.ketonegames.com
User avatar
zygoth
 
Posts: 140
Joined: Mon Jun 11, 2007 6:37 pm
Score: 5 Give a positive score

Re: strcmp and getactor questions

Postby makslane » Tue Jul 07, 2009 1:01 am

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";
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: strcmp and getactor questions

Postby skydereign » Tue Jul 07, 2009 2:04 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: strcmp and getactor questions

Postby zygoth » Tue Jul 07, 2009 1:03 pm

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
Nova: 100% Vertigo/Mazeman: 100%
Visit my website to download them both! http://www.ketonegames.com
User avatar
zygoth
 
Posts: 140
Joined: Mon Jun 11, 2007 6:37 pm
Score: 5 Give a positive score

Re: strcmp and getactor questions

Postby makslane » Tue Jul 07, 2009 1:44 pm

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: strcmp and getactor questions

Postby zygoth » Tue Jul 07, 2009 2:55 pm

What does it mean for a character to have a higher value than another character?
Nova: 100% Vertigo/Mazeman: 100%
Visit my website to download them both! http://www.ketonegames.com
User avatar
zygoth
 
Posts: 140
Joined: Mon Jun 11, 2007 6:37 pm
Score: 5 Give a positive score

Re: strcmp and getactor questions

Postby makslane » Tue Jul 07, 2009 3:25 pm

Means: D > A and X < Z
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: strcmp and getactor questions

Postby zygoth » Tue Jul 07, 2009 6:50 pm

ok, thanks.
Nova: 100% Vertigo/Mazeman: 100%
Visit my website to download them both! http://www.ketonegames.com
User avatar
zygoth
 
Posts: 140
Joined: Mon Jun 11, 2007 6:37 pm
Score: 5 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron