Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do i make clones move seperately
- NearTheVan
-
Scratcher
2 posts
How do i make clones move seperately
i'm trying to make a frogger game and want to make the obstacles go to their places without making different sprites.
when green flag clicked
repeat (10)
create clone of [ myself]
change y by (40)
end
Last edited by NearTheVan (June 21, 2023 21:49:08)
- 09878901234321
-
Scratcher
500+ posts
How do i make clones move seperately
Can you link to the project?
- Woodfur
-
Scratcher
100+ posts
How do i make clones move seperately
Clones start with whatever properties the original had when they were created. So you can set the properties before making each clone, and if there's any kind of pattern to those properties, you can find a way to do them in a loop.
Another way is to have the clone use contextual information to figure out what it should set its properties to. So combining those approaches, maybe you move your original sprite from top to bottom to create a column of clones, and those clones use the mod 3 of their y position to figure out whether they should go to the left edge, the right edge, or delete themselves. Or, similarly, just set a “for this sprite only” variable that counts how many clones have been made and let them figure out their own y position from that.
Edit: Actually, “touching color” would be a useful context clue if you want to generate obstacles for different backdrops, as long as you make the leftbound and rightbound roads a subtly different shade and keep the spacing regular.
Another way is to have the clone use contextual information to figure out what it should set its properties to. So combining those approaches, maybe you move your original sprite from top to bottom to create a column of clones, and those clones use the mod 3 of their y position to figure out whether they should go to the left edge, the right edge, or delete themselves. Or, similarly, just set a “for this sprite only” variable that counts how many clones have been made and let them figure out their own y position from that.
Edit: Actually, “touching color” would be a useful context clue if you want to generate obstacles for different backdrops, as long as you make the leftbound and rightbound roads a subtly different shade and keep the spacing regular.
Last edited by Woodfur (June 21, 2023 22:26:22)
- Zydrolic
-
Scratcher
1000+ posts
How do i make clones move seperately
i'm trying to make a frogger game and want to make the obstacles go to their places without making different sprites.when green flag clicked
repeat (10)
create clone of [ myself]
change y by (40)
end
when green flag clicked
repeat until <> // equivalant of forever but less laggy
create clone of [myself]
change [LilypadCloneID] by (1)
if <[(LilypadCloneID)] = [MaxLanes(use number)]> then
set [LilypadCloneID)] to (0)
wait (0.54) secs // lazy to check + depends on player speed.
end
end
when I start as a cloneHope that helps in a way. Although you'll have do this for each ID…
if <[(LilypadCloneID)] = [1]> then // first lane, left
set y to (value)
set x to (299)
repeat until <[(x position)] = [-299]> // correct this to the other side of the screen
change x by (speed)
end
end
if <(LilypadCloneID)] = [2]> then // second lane, right
set y to (value)
set x to (-299)
repeat until <[(x position)] = [299]> // correct this to the other side of the screen
change x by (speed)
end
end
if <(LilypadCloneID) = [3]> then // third lane, left
set y to (value)
set x to (299)
repeat until <[(x position)] = [-299]> // correct this to the other side of the screen
change x by (speed)
end
end
if <(LilypadCloneID)] = [4]> then // fourth lane, right
set y to (value)
set x to (-299)
repeat until <[(x position)] = [299]> // correct this to the other side of the screen
change x by (speed)
end
end
So, if you're trying to make it endless — Then sadly you'll have to look for a different answer.
Cheers!
EDIT: No custom blocks. That's just an error I'm lazy to fix. Probably typed something wrong init.
Last edited by Zydrolic (June 22, 2023 07:42:30)
- Discussion Forums
- » Help with Scripts
-
» How do i make clones move seperately



