Discuss Scratch

ResExsention
New Scratcher
1000+ posts

Clones targeting clones

Sort of like (pseudocode):

if clone a gets too close to any clone b:
tell clone a to start shooting at nearest clone b

The clones are from two different sprites, and there will be multiple clones. How could I accomplish something like this?

I'm looking for generic answers here, so please don't ask me to share the project…
deck26
Scratcher
1000+ posts

Clones targeting clones

Search in Scratch for ‘nearest clone’ and you should find something that will help.
ResExsention
New Scratcher
1000+ posts

Clones targeting clones

deck26 wrote:

Search in Scratch for ‘nearest clone’ and you should find something that will help.

Not exactly the answer I was expecting, but thanks for the tip…
ResExsention
New Scratcher
1000+ posts

Clones targeting clones

Uh, bump. @deck26 didn't exactly give me the answer I'm looking for. Also, clone b should be able to target clone a in reverse.
deck26
Scratcher
1000+ posts

Clones targeting clones

ResExsention wrote:

Uh, bump. @deck26 didn't exactly give me the answer I'm looking for. Also, clone b should be able to target clone a in reverse.
If a has identified b as a target it is trivial enough to set a variable or two and send a broadcast or use lists to match pairs of clones of different sprites. All of this has been done by others.
Nambaseking01
Scratcher
1000+ posts

Clones targeting clones

Huh. Let me do some messing with clones and return to you.
ResExsention
New Scratcher
1000+ posts

Clones targeting clones

deck26 wrote:

ResExsention wrote:

Uh, bump. @deck26 didn't exactly give me the answer I'm looking for. Also, clone b should be able to target clone a in reverse.
If a has identified b as a target it is trivial enough to set a variable or two and send a broadcast or use lists to match pairs of clones of different sprites. All of this has been done by others.

Ohhhhh

That clears up a lot of things and was definitely more useful. Thanks.

Nambaseking01 wrote:

Huh. Let me do some messing with clones and return to you.

Yeah. Before I start anything I'll see what you have to say.
Nambaseking01
Scratcher
1000+ posts

Clones targeting clones

Ahh

I tried everything I could, so I think the script should be something like adding the x and y positions to a list and keep counting the itinerary, and then you should probably mess around with the distance value so it arrives at a script that detects when it is close to the sprite/clone. Then the clone should select a random value in the list using the itinerary and point in that direction and start shooting. And of course, the hurt scripts in the clone events.

Hopefully this worked. And sorry for the long wait, I came after a good night's sleep.
deck26
Scratcher
1000+ posts

Clones targeting clones

The

Nambaseking01 wrote:

Ahh

I tried everything I could, so I think the script should be something like adding the x and y positions to a list and keep counting the itinerary, and then you should probably mess around with the distance value so it arrives at a script that detects when it is close to the sprite/clone. Then the clone should select a random value in the list using the itinerary and point in that direction and start shooting. And of course, the hurt scripts in the clone events.

Hopefully this worked. And sorry for the long wait, I came after a good night's sleep.
There are examples with and without lists.
cannonball84
Scratcher
58 posts

Clones targeting clones

My Solution:

Just make the whole project into lists and pen (ideally stamp), that way there wont be overly complected issus like this
Nambaseking01
Scratcher
1000+ posts

Clones targeting clones

cannonball84 wrote:

My Solution:

Just make the whole project into lists and pen (ideally stamp), that way there wont be overly complected issus like this

Stamps cannot move — so Res has to use clones.
deck26
Scratcher
1000+ posts

Clones targeting clones

Nambaseking01 wrote:

cannonball84 wrote:

My Solution:

Just make the whole project into lists and pen (ideally stamp), that way there wont be overly complected issus like this

Stamps cannot move — so Res has to use clones.
That's no reason why not, just means the screen needs redrawing each frame which is not unusual for pen projects.
ResExsention
New Scratcher
1000+ posts

Clones targeting clones

deck26 wrote:

Nambaseking01 wrote:

cannonball84 wrote:

My Solution:

Just make the whole project into lists and pen (ideally stamp), that way there wont be overly complected issus like this

Stamps cannot move — so Res has to use clones.
That's no reason why not, just means the screen needs redrawing each frame which is not unusual for pen projects.

Nambaseking01 wrote:

cannonball84 wrote:

My Solution:

Just make the whole project into lists and pen (ideally stamp), that way there wont be overly complected issus like this

Stamps cannot move — so Res has to use clones.

The reason why I am using stamps is because I have complex art planned. No way I'm going to try to figure that out with pen…

Thanks, though. Nammy, I'll try your suggestion.
Nambaseking01
Scratcher
1000+ posts

Clones targeting clones

ResExsention wrote:

~snip~
Thanks, though. Nammy, I'll try your suggestion.

Work notification, please.

Powered by DjangoBB