The Daily Click ::. Forums ::. Klik Coding Help ::. Going crazy with multiple instances
 

Post Reply  Post Oekaki 
 

Posted By Message

ugo



Registered
  07/11/2008
Points
  3
17th February, 2009 at 15:16:38 -

Hello there, I'm ugozzolo, from Italy.
I've been around for a while here on TDC, always found the right help for my nooby skills, you guys are awesome.

But, this time I have a problem I couldn't solve by just searching on the site, really hope you can help me.... It concerns dealing with multiple instances.

I'm developing a sort of platform game: you control the player with WASD and use the mouse to interact with the environment; the mouse is the player's "hand", you can drag and drop things and/or eat them. Since you are a monster, you need to eat human beings( ) which are represented by just one active object -yeah, everybody will look the same- . All the humans ARE AFRAID of you and of YOUR HAND, or at least most of them, probably I'll put an "infantry" object under the same group, but first things first.

Now the problem is, I've been trying to learn how fastloops work for weeks, but I didn't really understand the tutorials, and all the example links I've checked were broken ( there are A LOT of them!!),google didn't help me either....until I've discovered DeadmanDines' tutorial about Handling Multiple Objects using alterable strings( http://www.create-games.com/article.asp?id=1960 ). So, I've assigned various status-named strings (e.g. "is stopped", "can see","action" etc.) and when 2 of them were true, the proper string turned on - in this case,the "action" one-, activating the action.
It did work somehow, even using only 2 strings of three, "see" and "action":

:mouse pointer over HUMAN ----> set string "see" of HUMAN to "YES"
:string "see" of HUMAN= "YES" -----> set string "action" of HUMAN to "RUN"
:string "action" of HUMAN= "RUN"------> the human runs away.

...obviously, I've also determined what should happen if the mouse pointer is NOT over HUMAN, if "see" is on the "NO" value, etc.

Coding this way makes the only human with the mouse over him to run away, no influence on his other copies.



Things start to get messy when I want to assign a sight detector: when the mouse is over it, the human should see you, or your hand, from distance,eventually trying to escape.
On frame start, I create an active object named SIGHT DETECTOR and I put it under the group PEOPLE: so, for every human on screen,a SIGHT DETECTOR is created and sticked to PEOPLE's coordinates.Then, the new instance handling code is:

mouse pointer over SIGHT DETECTOR ----> set string "see" of HUMAN to "YES"
:string "see" of HUMAN= "YES" -----> set string "action" of HUMAN to "RUN"
:string "action" of HUMAN= "RUN"------> the human runs away.

Now, when the mouse is over ANY of the detectors, EVERYBODY flee away screaming in terror!!!
Probably, the reason is that I need to define WHICH detector has the mouse pointer over, but

how can I bound them with other alterable strings if the only thing they need to do is to detect and activate one other object's status?

Plus, and I think that's an even noobish issue, I don't know why but when I destroy an human the others stay on screen, when all of their detectors disappear leaving them....well, blind.

Can you guys please help me,suggesting a better method or a proper code? It's not I'm in love with alterable strings, it's just that when I try to fastloop events or spread values everywhere it never works. I'm looking for a solution which could deal with a large number of instances. I'm sooo frustrated!!

Thank you ...

(Ah, forgive me for grammar mistakes or if I've been confusing , it's hard to explain this kind of stuff in English... Sorry )

 
n/a

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49567

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
18th February, 2009 at 00:58:08 -

Make one detector that follows your mouse, when THAT detector overlaps a human then activate the appropriate actions.

On a side note you could also use a loop to calculate the distance from each human, then make him run according to the threat level(Based on how far away the mouse is) OR, you could make a new Alternate Value called "FearLevel" and when the detector overlaps him set it to 100 or something, and when the detector is not over him lower the value. When the value equals zero deactivate his scared action.

Edited by UrbanMonk

 
n/a
   

Post Reply



 



Advertisement

Worth A Click