Discuss Scratch

archmage
Scratcher
6 posts

How to identify specific clones?

Cloning is a pretty neat feature but I realized pretty pretty quickly that there is no particular blocks to identify which specific clone is touching another clone. For instance, I have my bullet, cloned sprites named “Shot” and my enemy cloned sprites named “Baddy”. I can tell if a Shot clone is touching one of the clones of Baddy but if I wanted to identify which particular clones are touching it is kinda difficult. Any one find any good workarounds?
billyjoebob
New to Scratch
3 posts

How to identify specific clones?

Inside the Baddy object, ‘if touching Shot’ will be true only when this particular clone is touched by a Shot. So each Baddy clone knows when it is touched, but not which particular Shot touched it. Similarly each Shot knows when it touches a Baddy, but not which particular Baddy.
archmage
Scratcher
6 posts

How to identify specific clones?

Well the reason I want to know which particular clone is touching which is so that I can check its local variables and other properties.

Here is a realistic example,


We have our hero, “Mario” and the stage is made of 120 cloned tiles. Now, tiles make up both the walls and the background bushes/clouds. Mario should be stopped by a tile as long as its “Walkable” variable is set to 1 rather than 0. Now this is rather annoying since I can't reference specific tile clones directly, I will probably have to use some roundabout way of checking its properties using broadcasts but this is annoying
BoltBait
Scratcher
1000+ posts

How to identify specific clones?

Check out this project: http://scratch.mit.edu/projects/10063618/

Sometimes it is not necessary to identify a specific clone in order for your scripts to work.

Click to play:
xlk
Scratcher
100+ posts

How to identify specific clones?

Well, how about you have a sprite that's a ball with physics, and you have 7 clones and you want them to interact. HOW?

billyjoebob
New to Scratch
3 posts

How to identify specific clones?

archmage wrote:

We have our hero, “Mario” and the stage is made of 120 cloned tiles. Now, tiles make up both the walls and the background bushes/clouds. Mario should be stopped by a tile as long as its “Walkable” variable is set to 1 rather than 0.

Instead of using variables, clone two different tile sprites called Walkable and NotWalkable. Test if Mario is touching NotWalkable.

archmage wrote:

I will probably have to use some roundabout way of checking its properties using broadcasts but this is annoying

Scratch is designed to teach basic programming principles. It's very easy to use, but the cost of that is it also very limited. It was designed to be easy to draw backgrounds and detect background collisions by ‘if touching color’. It wasn't designed for tile-based games, scrolling games, etc. It can be made to do those things but it will take longer and the solutions will feel like hacks. If you find yourself spending a lot of time to work around these limitations it might be less effort to just learn a real programming language that gives you complete freedom.
andre_rifaut
Scratcher
100+ posts

How to identify specific clones?

First, as one said: the beauty of the code design wil be reflected in the beauty of the application. The basic idea of Twitter is made with a simple design. May be this way of thinking is made easier with Scrath than with other languages ? So what you can learn with Scratch is to force you to match a beautiful simple idea with a beautiful design.

The example about physics is a very good example. In physics, each “body” has its own way to behave, just like balls.
But when 2 or more “bodies” are interacting (collision, …) then they become a kind of “aggregated body” that has different laws that are sometimes additive, but sometimes not. How to design this “aggregated body” ?

For instance, let us asume that for each sprite/clone X, Scratch provides you a list L of all other sprite/clone that are touching X.
Now, how to compute the “physical vector of speed” that result from the collision and the “speed vector” and mass of each other sprite/clone they had before the collision?
Let us suppose that all this information is inside each sprite/clone (i.e. in variables that are not shared by other sprites/clones). How to exchange this information between touching sprite/clones ? Scratch should provide a way to communicate between sprite/clones ?

Why not asking Scratchers that like physics, or make a groupe of Scratcher to create some beautiful simple design to solve this problem without too many if … then … else if … then … else if …
xlk
Scratcher
100+ posts

How to identify specific clones?

How about setting object variables, like “set (sprite 2(clone<touching?>) (xspeed)) to (9)”. A block like that would be amazing. REALLY usefull.

Last edited by xlk (May 16, 2013 17:38:40)


darkness3560
Scratcher
100+ posts

How to identify specific clones?

Create a global variable called clone-counter.
Then, create a local variable on the “Shot” sprite called my-num
[scratchblocks
set to 0
repeat
create clone of
wait secs
change (clone-counter) by 1

when I start as a clone
set to (clone-counter)
[/scratchblocks
All you have to do to get the specific clone number is use:
[scratchblocks
( of
[/scratchblocks

The blocks plugin is broken.

Last edited by darkness3560 (May 16, 2013 22:25:39)

Ravensteel
Scratcher
25 posts

How to identify specific clones?

For problems like this with clone identity, but not reqarding touch, rather position, I have found that using a list to keep track of the positions of all the clones is quite useful. (Example: you have a variable list in which you store clone Y positions, another where you store their X positions. Using this, it is possible to determine the position of clones.) I advised ScratchUniverse on how to do this, and I believe that he implemented it to keep track of his clones.

I'm a cloud☁data engineer/mechanic, so if you need cloud help, click the blue cloud!
Ravensteel has recently made his own 3D engine and game!
Follow Ravensteel for instant alerts whenever a new project is released from his account!

RDoc
Scratcher
46 posts

How to identify specific clones?

Take a look at 3D BallShootArcade if you'd like. It identifies clones with global variables and keeps track of positions via global arrays.
doonkoo
Scratcher
100+ posts

How to identify specific clones?

darkness3560 wrote:

Create a global variable called clone-counter.
Then, create a local variable on the “Shot” sprite called my-num
[scratchblocks
set to 0
repeat
create clone of
wait secs
change (clone-counter) by 1

when I start as a clone
set to (clone-counter)
[/scratchblocks
All you have to do to get the specific clone number is use:
[scratchblocks
( of
[/scratchblocks

The blocks plugin is broken.
No it isn't. You forgot brackets ( ] )at the end of the [scratchblocks. See:
set [clone-counter v] to (0)
repeat [however many times]
create clone of [myself v]
wait [0] secs
change (clone-counter) by (1)

when I start as a clone
set [my-num v] to (clone-counter)
All you have to do to get the specific clone number is use:
([my-num v] of [Shot v]
Also, you need parentheses (something) around any inputs.
When there are no parentheses, this happens:
set [variable v] to number
When there are parentheses, it looks normal.
Also, does this kind of block even exist?
([my-num v] of [Shot v])
It doesn't.

Last edited by doonkoo (Sept. 29, 2013 17:28:42)


“I am pleased a book on science competes with the memoirs of pop stars. Maybe there is some hope for the human race.”
-Stephen Hawking

“Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world.”
-Albert Einstein

“I have noticed people who claim everything is predestined, and that there is nothing we can do to change it, look before they cross the road.”
-Stephen Hawking
Ravensteel
Scratcher
25 posts

How to identify specific clones?

@Doonkoo: Actually, that specific block does exist and does allow you to see sprite-specific variables.

I'm a cloud☁data engineer/mechanic, so if you need cloud help, click the blue cloud!
Ravensteel has recently made his own 3D engine and game!
Follow Ravensteel for instant alerts whenever a new project is released from his account!

JAVAProgramming
Scratcher
100+ posts

How to identify specific clones?

archmage wrote:

Cloning is a pretty neat feature but I realized pretty pretty quickly that there is no particular blocks to identify which specific clone is touching another clone. For instance, I have my bullet, cloned sprites named “Shot” and my enemy cloned sprites named “Baddy”. I can tell if a Shot clone is touching one of the clones of Baddy but if I wanted to identify which particular clones are touching it is kinda difficult. Any one find any good workarounds?
If you make a sprite specific variable, it transfers into a clone specific variable. So just do this:
when I start as a clone
Change (Clones) by 1
Set (CloneID) to (Clones)

Last edited by JAVAProgramming (Sept. 29, 2013 17:43:31)


My Newest Project, Come Check It Out
Dots, On Scratch
Want to change the way we count? The Dozenal System.

“The story so far:
In the beginning the Universe was created.
This has made a lot of people very angry and been widely regarded as a bad move.”
― Douglas Adams, The Restaurant at the End of the Universe
Meteor_mash47
Scratcher
1 post

How to identify specific clones?

Dont you just color all of the clones created to find out how many clones are generated
typemaster
Scratcher
100+ posts

How to identify specific clones?

You do not need to make a variable for each enemy. Add the sprites to lists. Example:


if <(Goomba1)<touching [Spiney 298]?> then
add [Goomba1] to [list touching]
add [Spiney 298] to [list touching what?]
end

Owner of TPM!!!!
when green flag clicked
forever
set [what I'm doing] to [playing destiny]
end
typemaster
Scratcher
100+ posts

How to identify specific clones?

Meteor_mash47 wrote:

Dont you just color all of the clones created to find out how many clones are generated

You may think that, but no.

Owner of TPM!!!!
when green flag clicked
forever
set [what I'm doing] to [playing destiny]
end
vidarfw02
Scratcher
100+ posts

How to identify specific clones?

Hi, maybe this small example project will help:

http://scratch.mit.edu/projects/23916401

In this project all clones updates a table if they are touching the cat or not. The cat is constantly watching the table and tells everybody which clone who is touching him….also all the other clones can see that a specific clone is touching the cat…



vidarfw02
Scratcher
100+ posts

How to identify specific clones?

Also made a clone touching clone detection example:

http://scratch.mit.edu/projects/23973803


minecrafternotch
Scratcher
3 posts

How to identify specific clones?

I created a game where if you click one clone a sprite will change costume?
How do I get a certain clone to be identified as one thing not another?

Powered by DjangoBB