Now there's the thing. Depending on what you are sorting it makes a huge difference. If you look at my depth sorting project on my tutor account, you'll find it uses a binary chop algorithm to speed up the sort. BUT, if the data you are sorting is already almost in the right order, then this method is actually much faster! IKR, I've timed it. So, yes, if your needing to sort a highly volatile set of sprites, then you may do well to use a more clever technique (which I can teach), but most of the time it would be wasted effort it appears.
@@griffpatch Sorting algorithms are really contextual. I mean, if you have just a few sprites - or any amount, honestly, you certainly wouldn't want to use something like Radix sort. But when you're sorting thousands upon thousands of elements at once, Insertion sort is just way too slow.
I love how elegant this solution is. I've never thought that sprites that are in front will run broadcasts first! I've always thought that they will retain their execution order regardless of their layer and it was a dead end for me, but you gave me enlightenment. I love your videos and the sheer amount of effort you put into them! Thanks for these tutorials!
@@Supyisiscool and the tricks he use are exclusive in the Scratch world. He has show the way to create incredible games (professional!) to thousands of Scratchers !
This video is immaculate and professional. As new scratcher, I am so glad there are people like you who make videos like these. So easy to understand and follow along. Thank you.
Man, you're the best. Your sorting script worked like a charm in a scrolling platformer game I'm working on. My layering was a mess, and pieces of the background kept either disappearing or showing in front of sprites where they didn't belong. It was such a headache. Now my layers work correctly *all* the time, every time - it's amazing. I can finally work on what matters in my game now. Thank you so much Griffpatch!
This will improve so many of my games! A lot of my top-down adventure games look rather ugly because of the terrible layering. This was super helpful! I love your childish and energetic style!
The mechanic that scripts run for the highest layered sprites/clones before moving to lower layered sprites/clones is a HUGE game changer! I'm surprised I never heard about it sooner in my nearly 6 years of in-and-out Scratch experience. You never explained how this works with the background scripts though. Would they take priority over sprite/clone scripts or be the last in line to run? The script you constructed in the video to sort layering was also really helpful as well. I'm working on a Scratch port/re-invention of the Monster Hunter game series in a top-down 2d environment (one I may post on this account) that I planned to use layering for to implement vertical attacks for both the player and monsters. While I'm yet to reach this stage of the game, I have been concerned on how I would implement an effective height system, especially with fluid layer changing that could collide and dislodge other layering. The straightforward and versatile solution you provided almost completely solved all of those problems. My only fear is performance with the complexity I'm already aiming for and the fact that I'm running this on Turbowarp's interpolation (even though that compiles the code into a more efficient state, I'm still fearful). With the script, I am including terrain such as cliffs, trees, shrubs, etc. as clones rather than part of the core terrain feature/collision tiles once I convert from single tile maps. I don't mind reaching the clone limit, of course, since I'm going to design the game around Turbowarp. However, with my plan being geared towards interconnected maps rather than smaller, screen sized maps, I have my doubts that even Turbowarp could handle it with my limited testing of Turbowarp by running 5 Among Us games to cheat and win every time (don't question that). If you have any ideas about improving the efficiency of the layering script (both you, Griffpatch, and anyone else reading), I'd highly recommend advice.
I want to say something. I found something not right while watching this video. I don't know whether other people found this or not. When the cat goes to the front layer pass from the tree...It passed the tree trunk and popped out.. * That does not exactly happen in reality. * In reality, the cat cannot pass through the solid trunk. So, I'm thinking; will that bug be fixed in the next episode?
It's been years since I used scratch, but this video popped up and my feed and I clicked on it. Brings back memories and holy frick they completely revamped the UI
When the scratch is sus. This is a really great tutorial. Among us in the background. How did you make the scratch cat's 3d at this part: 4:06? I also have camtasia.
This is just scratch... I'm afraid it's Scratch switching the editor from one sprite to another... It probably won't happen when the game is played with the editor closed before you look inside. Also, if you change the dragging code to use a keypress instead of the click then that solves the problem... it's not your fault.
ive been searching through and analyzing every frame of this video trying to figure out where i went wrong but i literally cant find anything that isnt exactly how this tutorial showed it. it just doesnt work.
Same here, when I run the sorter in an infinite loop, my clones sometimes just go back and forth, which looks like flickering when they are layered on top of one another
Thank you so much griffpatch! I have a big game i was almost finished releasing the demo for and I kept putting off the layering of it. When i finally got around to it, It was a nightmare sorting everything and trying to get it to work properly, but this helped out a ton!
7:23 or just a suggestion you could have the sprites set a new variable to their y position, and compare if the order is bigger than 1, before setting the variable, comparing it to the previous position (stored in variable), and, if placed higher up, goes to back layer, on the flip side, going up 1 layer, because they run in layer order, therefore they can compare the variable to their own data edit: i didnt think of doing this because i didnt know they ran the broadcast code in layer order, however i did know they ran in seperately
Hi, I was wondering how do you make it that you can overlap two sprites and then make the outline blend together so that you can't determine on what layer they are.
Thank you! I'm using this for a sokoban game, as I want "floor" objects (like markings on the ground) to layer below everything else, but all the objects are clones in the same sprite
Thank you for this! There aren't many advanced tutorials on scratches layering. I am making a top-down shooter game so layering is of the utmost importance. Unfortunately, I am not using this. I made my own layering system a while back that I'm using but this is great stuff!
This is so useful to sort layers in projects, I was confusing to sort them in my projects that I'm just using the go to front layer blocks and it fianlly not working but this would just become so useful that you can just enter the layer in the block and it will sort it for you
im not sure how efficient or if its even functional or applicable on scratch, but maybe it could be done with "go to back layer" and then "go forward (0 - (y position - 200)) layers" or something of that kind to sort in 2d? either way great video, learned a ton. cheers!
griffpatch, i tired this code but at the current time continuous ordering, the list is deleted and doesn't have enough time to reorder everything before it is deleted again. do you know how to fix this?
I am using the broadcast and say layers change layer by 1 and i have a sprite that uses a go to front block but it only goes tk layer 14 when other sprites that use go forward 1 layer are at 35
Did anyone spot the little among us red impostor during the showcase of how the scratch go forward and go to front layer block are bad??? Please don’t say I’m the only one!!! Impostor here -> 4:10
with the clone block i made it "make clone (Amount) of me" i dragged the amount into the repeat block so you could then make as much as you need you can then also make a slider variable for it
I was following this tutorial and at 18:20 scratch decided to not count my i variable as a variable but just... I'm not actually sure. I replaced it with another i variable and it was fine. Really weird glitch!
for me as it appears, cats at the front layer start glitching out uncontrolably, it seems to be something related to the i variable randomly becoming flashing beetween 1 and 8, help?
I've seen this script so many times my ELA grade dropped | edit: I've even realized it is faster to skip to a point where the finished script is there ( sorting script 28:12 ) ( event 21:34 ) ( also fun fact, reading code by someone else can help you understand the meaning of a block! )
I think there is a more simple way because I have messed around with layers and you can tell the sprite or clone to go to the front and then tell it it go back a number of layers based off of the Y position. so, for example the Y position of one is 50 so it will go back 50 layers behind one that would have a lower y position
23:57 ¨-180 to180¨ if you would keep it at that it would mean a higher chance of you getting 180 because 180=-180 in this situation i put it at -179 to 180
Why not use a more efficient sorting algorithm?
Now there's the thing. Depending on what you are sorting it makes a huge difference. If you look at my depth sorting project on my tutor account, you'll find it uses a binary chop algorithm to speed up the sort. BUT, if the data you are sorting is already almost in the right order, then this method is actually much faster! IKR, I've timed it. So, yes, if your needing to sort a highly volatile set of sprites, then you may do well to use a more clever technique (which I can teach), but most of the time it would be wasted effort it appears.
@@griffpatch Sorting algorithms are really contextual. I mean, if you have just a few sprites - or any amount, honestly, you certainly wouldn't want to use something like Radix sort. But when you're sorting thousands upon thousands of elements at once, Insertion sort is just way too slow.
@@griffpatch sussy mogus (O3 sus lol
@@hriday684 but it's not too slow if your items are almost in the correct order already. Which is what we have most of the time in scratch
@@hriday684 say contextual but replace conte with se and remove the 2nd t”t”
I love how elegant this solution is. I've never thought that sprites that are in front will run broadcasts first! I've always thought that they will retain their execution order regardless of their layer and it was a dead end for me, but you gave me enlightenment.
I love your videos and the sheer amount of effort you put into them! Thanks for these tutorials!
I like griffpatch's tutorials because you actually understand them. Unlike the other ones, where you just copy everything.
Agreed
@@tankyd8229 True
@@MrPork-he5lz very true
@@Supyisiscool and the tricks he use are exclusive in the Scratch world. He has show the way to create incredible games (professional!) to thousands of Scratchers !
I agree
“A complete jumble, a mess of cats!”
That’s the basic definition of half of Scratch’s first projects ( or something like that. ), including me.
This is one of the best tutorials on the entirety of RUclips
This is great! My money was worth it to see these tutorials early! Nice Griffpatch!
8 hours ago?!?! This was posted 2 minutes ago.
@@TirzaBoi thy can see the video early cause of their subscription
@@MrPuzzleCodes oh yeah i forgor ☠️
Boy does this guy love the scratch cat, he even put in in the title of the video, and its the main character in almost every video.
This video is immaculate and professional. As new scratcher, I am so glad there are people like you who make videos like these. So easy to understand and follow along. Thank you.
Man, you're the best. Your sorting script worked like a charm in a scrolling platformer game I'm working on. My layering was a mess, and pieces of the background kept either disappearing or showing in front of sprites where they didn't belong. It was such a headache. Now my layers work correctly *all* the time, every time - it's amazing. I can finally work on what matters in my game now. Thank you so much Griffpatch!
The great thing with griffpatch's tutorials is that they are easy to learn unlike other people who put in as much as possible.
This will improve so many of my games! A lot of my top-down adventure games look rather ugly because of the terrible layering. This was super helpful! I love your childish and energetic style!
I've already tested this technique and failed miserably. I love this tutorial and all of the ones like it! I wish the best of luck to you griffpatch!
The edits during this video look really neat and make this super easy to understand! Great video as always.
Glad you think so!
When He Said "The Fun Is Quite Endless" 27:28 I Was Like Majin Sonic LOL
I dont know why but a ton of scratch cats bouncing around the screen like the dvd logo was oddly hilarious to me
The mechanic that scripts run for the highest layered sprites/clones before moving to lower layered sprites/clones is a HUGE game changer! I'm surprised I never heard about it sooner in my nearly 6 years of in-and-out Scratch experience. You never explained how this works with the background scripts though. Would they take priority over sprite/clone scripts or be the last in line to run?
The script you constructed in the video to sort layering was also really helpful as well. I'm working on a Scratch port/re-invention of the Monster Hunter game series in a top-down 2d environment (one I may post on this account) that I planned to use layering for to implement vertical attacks for both the player and monsters. While I'm yet to reach this stage of the game, I have been concerned on how I would implement an effective height system, especially with fluid layer changing that could collide and dislodge other layering. The straightforward and versatile solution you provided almost completely solved all of those problems.
My only fear is performance with the complexity I'm already aiming for and the fact that I'm running this on Turbowarp's interpolation (even though that compiles the code into a more efficient state, I'm still fearful). With the script, I am including terrain such as cliffs, trees, shrubs, etc. as clones rather than part of the core terrain feature/collision tiles once I convert from single tile maps. I don't mind reaching the clone limit, of course, since I'm going to design the game around Turbowarp. However, with my plan being geared towards interconnected maps rather than smaller, screen sized maps, I have my doubts that even Turbowarp could handle it with my limited testing of Turbowarp by running 5 Among Us games to cheat and win every time (don't question that). If you have any ideas about improving the efficiency of the layering script (both you, Griffpatch, and anyone else reading), I'd highly recommend advice.
"I feel sorry for that chick."
**Proceeds to delete him from existence*
04:12 AMONG US.
AWESOME TUTORIAL 😄
YES
THANK YOU SO MUCH FOR THIS! This is the most useful tutorial I’ve ever watched in all of tutorials ever!!
"trees don't tend to walk around" - Griffpatch 2021
i made the 1000th comment so that hopefully this video will get recommended to more people it's such a good tutorial
I want to say something. I found something not right while watching this video. I don't know whether other people found this or not.
When the cat goes to the front layer pass from the tree...It passed the tree trunk and popped out..
* That does not exactly happen in reality.
* In reality, the cat cannot pass through the solid trunk.
So, I'm thinking; will that bug be fixed in the next episode?
little question how do you get the number of clones and the position of each tings next to the green flags?
10:19 I love when you do animations to explain how a script work 😸
@@X-tra_power yes he is strange 😂😂
@Angus1637 ????? 😂
4:08 made me appreciate Griffpatch's efforts even more in animating his videos to make it easier to understand.
@@spiritsk88 among us
It's been years since I used scratch, but this video popped up and my feed and I clicked on it. Brings back memories and holy frick they completely revamped the UI
4:11 best easter egg so far
This is actually very useful, thanks Griffpatch.
THIS IS PERFECT FOR A HIDE N SEEK GAME!
I literally trying every single video, keep it up Griffpatch, your tutorials are so helpful
This is seriously a thing we all need / needed at one point
Can you do a learning ai next?
If you use lists to keep track of punishments and rewards I'm sure it's possible
Use cloud for the punishments
if we use cloud for punishments there will be an extremely long tangent on cloud lists
25:15 For multiple clone types, you can use costumes instead but it will be more complex but atleast it will load as fast as possible.
this is awesome! top down games are going to look so good thanks to this!
4:50 Yay, finally we get to order some Sprites! I was getting thirsty!
When the scratch is sus. This is a really great tutorial. Among us in the background. How did you make the scratch cat's 3d at this part: 4:06? I also have camtasia.
I used the rotate feature on each layer, but had to move them manually in the X direction to make it look right.
i see a red bean with legs with a blue plate and a backpack
@@jasondevelopz that's an among us character
@@shng8528 and that’s what he was talking about
@@shng8528 ik its a joke
19:13 this is the first time that I have this trick so i'm excited 🔥
This is awesome 😲
Wow! I am impressed with these best scratch tutorials! Can you also make a hard game from scratch? And keep Scratching!
Probably the only time Griffpatch used a sprite from the Scratch-Sprite Library! Great video griffpatch.
he used the apple asset in the pathfinding tutorial
It's Great! But, When I Click, Things are Just Starting to Get a Bit Lag...
This is just scratch... I'm afraid it's Scratch switching the editor from one sprite to another... It probably won't happen when the game is played with the editor closed before you look inside. Also, if you change the dragging code to use a keypress instead of the click then that solves the problem... it's not your fault.
@@griffpatch Really? But When I Followed the Coding Insertion Sort, And I Clicked It, and Cube: I Just Got Many Times, and Things Just Gets Lag. HELP.
This just gave me an idea that you should make a advanced rpg/adventure game when you have time
ive been searching through and analyzing every frame of this video trying to figure out where i went wrong but i literally cant find anything that isnt exactly how this tutorial showed it. it just doesnt work.
You found out yet?
@@Funni_Stuff buddy I don't even remember doing this or care by now it's been a YEAR.
I moved on from scratch and am good at unity by now brother.
@@idoblenderstuffs Nice job learning unity!
Same here, when I run the sorter in an infinite loop, my clones sometimes just go back and forth, which looks like flickering when they are layered on top of one another
Thank you so much griffpatch! I have a big game i was almost finished releasing the demo for and I kept putting off the layering of it. When i finally got around to it, It was a nightmare sorting everything and trying to get it to work properly, but this helped out a ton!
4:13 AMONG US
Bum BUM
pu Pu PU PU PU PU PUUU
Would adding scrolling make this effect unusable?
Probably no
you put appel and lemons but now u put among us WHY AaAaAaAaAaAaAaAaAaAaAaAaAaAa
Yo what the actual ****ing sus thing you are talking
24:35 Everything is good until you notice the black dot in the top right of the stage
I love your videos griff! They are the best tutorials I’ve ever seen! (Also griffpatch, I’m not trying to beg, but we need more 3d raycater episodes!)
Awesome tutorial! Hope to put it to use some time soon...
Thanks Milan :)
Griffpatch makes me look forward to the start of the week : )
7:23 or just a suggestion you could have the sprites set a new variable to their y position, and compare if the order is bigger than 1, before setting the variable, comparing it to the previous position (stored in variable), and, if placed higher up, goes to back layer, on the flip side, going up 1 layer, because they run in layer order, therefore they can compare the variable to their own data edit: i didnt think of doing this because i didnt know they ran the broadcast code in layer order, however i did know they ran in seperately
Hi, I was wondering how do you make it that you can overlap two sprites and then make the outline blend together so that you can't determine on what layer they are.
i think the only way to do it is with complicated math, so either figure it out yourself, or wait for griffpatch
I like these tutorials because they are easy to understand even if complex I have watched a few tutorials because they are easy to learn
1:27 why is appel there
you are the best teacher in the entire world
Omg!!! This is perfect for my game!!!!! 🤩🤩🤩 THANK YOU GRIFFPATCH!!!!! YOU'RE THE BEST!!!!!
so helpful, I made a 3d gravity simulation with this, thank you!
Nano finally got a smile on his face! (This is his world, not that scary Raycaster!)
Griffpatch, you are a genius!
Thank you! I'm using this for a sokoban game, as I want "floor" objects (like markings on the ground) to layer below everything else, but all the objects are clones in the same sprite
I’m working on an RPG rn (not ur rpg) and I can’t seem to figure out the permanent sprite layering trick.
It's permanent because we stamp layer 3 last, which is the only layer that appears above the player.
@@griffpatch May I share the project to u?
and u take a look
in 4:12 there is among us in a part can you find it?
Thanks! This really helped me learn!
You are a excellent Coder
Thank you for this! There aren't many advanced tutorials on scratches layering. I am making a top-down shooter game so layering is of the utmost importance. Unfortunately, I am not using this. I made my own layering system a while back that I'm using but this is great stuff!
lol i had my own way of doing layering but your way is super efficient and much better. cool that you found a much easier way to do it
This is so useful to sort layers in projects, I was confusing to sort them in my projects that I'm just using the go to front layer blocks and it fianlly not working but this would just become so useful that you can just enter the layer in the block and it will sort it for you
Absolutely, so useful right
I'm going to use what I learned from this video to layer the towers and enemies in my tower defence project.
finally, i've been wanting this for a while
im not sure how efficient or if its even functional or applicable on scratch, but maybe it could be done with "go to back layer" and then "go forward (0 - (y position - 200)) layers" or something of that kind to sort in 2d? either way great video, learned a ton. cheers!
Griffpatch's Videos Are Awesome! Bro!
This is literally what I needed
I don't get tired of saying this but all your tutorials are very useful
hi griffpatch can you make a tutorial titled how to make a cloud list pls
4:12 damm bro griffpatch be a lil humorous
Thanks! This was really useful for my isometric Minecraft: Scratch Edition project I'm working on!
griffpatch, i tired this code but at the current time continuous ordering, the list is deleted and doesn't have enough time to reorder everything before it is deleted again. do you know how to fix this?
sorry. tried
also it still doesn't work
18:05 Haha thank you griffpatch ❤️✨
28:44 if you look left of the screen 2 scratch cat bounc off of each other i dont know if it the code or what
I am using the broadcast and say layers change layer by 1 and i have a sprite that uses a go to front block but it only goes tk layer 14 when other sprites that use go forward 1 layer are at 35
Thanks Griffpatch! you're the best Scratcher!
Did anyone spot the little among us red impostor during the showcase of how the scratch go forward and go to front layer block are bad??? Please don’t say I’m the only one!!! Impostor here -> 4:10
with the clone block i made it "make clone (Amount) of me" i dragged the amount into the repeat block so you could then make as much as you need you can then also make a slider variable for it
That was a great tutorial. :)
Glad you liked it :)
I was following this tutorial and at 18:20 scratch decided to not count my i variable as a variable but just... I'm not actually sure. I replaced it with another i variable and it was fine. Really weird glitch!
for me as it appears, cats at the front layer start glitching out uncontrolably, it seems to be something related to the i variable randomly becoming flashing beetween 1 and 8, help?
Very useful!
Yes! Great video Griffpatch!
And of course - chickens for the win. That got me.
griffpatch back at it with the banger videos
I've seen this script so many times my ELA grade dropped | edit: I've even realized it is faster to skip to a point where the finished script is there ( sorting script 28:12 ) ( event 21:34 ) ( also fun fact, reading code by someone else can help you understand the meaning of a block! )
griffpatch: 28:53 "all alone and not moving any where, i feel sorry for it"
proceeds to hide it from existents
I think there is a more simple way because I have messed around with layers and you can tell the sprite or clone to go to the front and then tell it it go back a number of layers based off of the Y position. so, for example the Y position of one is 50 so it will go back 50 layers behind one that would have a lower y position
Is it possible to set the layer where each sprite is located to the opposite number of its y-coordinate
Thank you so much Griffpatch! I needed sprite sorting for my new platformer and this has helped out a ton!
This is exactly what I was looking for
I'm having as much fun with this as you griffpatch! Thanks!
This is really useful, I've always wanted this. (also I saw something sus at 4:13 )
Do you think you can add collision with the cat and tree ?
This Goes Great with Z Position!
23:57 ¨-180 to180¨ if you would keep it at that it would mean a higher chance of you getting 180 because 180=-180 in this situation i put it at -179 to 180
Awsome!! This Is Very Useful Thanks!!