Discuss Scratch

Cyks
Scratcher
100+ posts

Using lists to save and update the current X and Y of many clones

So what I have is two sprites. Sprite1 stays in one spot and is hidden, but it creates clones of itself and these clones move around the screen until they touch the edge then they delete themselves. Now I have sprite2 creating a clone for every sprite1 clone and the clones need to always go to the X and Y of the sprite1 clones. I think the best way to do this is to use lists. I have two lists, one for the X position of the sprite1 clones, and one for the Y position of the sprite1 clones. Every time a clone of sprite1 is created it needs to add its X position to the X list and the Y to the Y list, also constantly updating them. The X and Y data for one clone on the lists need to be deleted if the clone is deleted. Then every time sprite2 starts as a clone it finds an X and Y on the lists that another sprite2 clone is not following and constantly goes to it. So for example, if ten clones of sprite1 are created then there should be 10 slots on each list (X and Y) that are constantly updating. Then ten sprite2 clones are created and they need to each constantly go to a different X and Y on the lists then the other clones. First question: will this work? XD Second question: can anyone help me? lol

brodzik
New to Scratch
3 posts

Using lists to save and update the current X and Y of many clones

Pogadasz ze mną
Dan0510
Scratcher
100+ posts

Using lists to save and update the current X and Y of many clones

I think I know how to do it.
Here's a tip:
You need a self made block where you give every clone a different ID (by using a counter variable which changes by 1 when a clone is created).
Does the tip help or should I create a project with my solution?

Kenichi10B
Scratcher
74 posts

Using lists to save and update the current X and Y of many clones

Sure, I'll help (And you're right about using lists). I'll leave a link when its done!


EDIT: Instead of using 2 lists for X and Y positions, you can use just 1.

Last edited by Kenichi10B (April 26, 2014 07:39:07)

Cyks
Scratcher
100+ posts

Using lists to save and update the current X and Y of many clones

Dan0510 wrote:

I think I know how to do it.
Here's a tip:
You need a self made block where you give every clone a different ID (by using a counter variable which changes by 1 when a clone is created).
Does the tip help or should I create a project with my solution?
Do you mean using the self made blocks with the list solution that I talked about? Because I want to use the list solution in my project. (sorry I didn't see this post until now)

Kenichi10B wrote:

Sure, I'll help (And you're right about using lists). I'll leave a link when its done!


EDIT: Instead of using 2 lists for X and Y positions, you can use just 1.
Thanks! How is it possible to use just one list for the X and Y? o.O

Dan0510
Scratcher
100+ posts

Using lists to save and update the current X and Y of many clones

I mean that you have a block with a number input (the clone “ID”/the spot in the list he uses) so the clone can set his position in the list(s). I hope that was clear enough

Kenichi10B
Scratcher
74 posts

Using lists to save and update the current X and Y of many clones

Cyks wrote:

Dan0510 wrote:

I think I know how to do it.
Here's a tip:
You need a self made block where you give every clone a different ID (by using a counter variable which changes by 1 when a clone is created).
Does the tip help or should I create a project with my solution?
Do you mean using the self made blocks with the list solution that I talked about? Because I want to use the list solution in my project. (sorry I didn't see this post until now)

Kenichi10B wrote:

Sure, I'll help (And you're right about using lists). I'll leave a link when its done!


EDIT: Instead of using 2 lists for X and Y positions, you can use just 1.
Thanks! How is it possible to use just one list for the X and Y? o.O

It's somewhat complicated to explain in the forums, but when I finish the project, I'll leave a comment in it so you can see.

EDIT: Done! The link is: http://scratch.mit.edu/projects/21229709/. Hope it works for you!

Last edited by Kenichi10B (April 29, 2014 11:31:06)

Cyks
Scratcher
100+ posts

Using lists to save and update the current X and Y of many clones

Kenichi10B wrote:

Cyks wrote:

Dan0510 wrote:

I think I know how to do it.
Here's a tip:
You need a self made block where you give every clone a different ID (by using a counter variable which changes by 1 when a clone is created).
Does the tip help or should I create a project with my solution?
Do you mean using the self made blocks with the list solution that I talked about? Because I want to use the list solution in my project. (sorry I didn't see this post until now)

Kenichi10B wrote:

Sure, I'll help (And you're right about using lists). I'll leave a link when its done!


EDIT: Instead of using 2 lists for X and Y positions, you can use just 1.
Thanks! How is it possible to use just one list for the X and Y? o.O

It's somewhat complicated to explain in the forums, but when I finish the project, I'll leave a comment in it so you can see.

EDIT: Done! The link is: http://scratch.mit.edu/projects/21229709/. Hope it works for you!
Thanks! This is really helpful! ^_^ (sorry for the late reply)

Kenichi10B
Scratcher
74 posts

Using lists to save and update the current X and Y of many clones

np, hope it helped you!

Powered by DjangoBB