Perfect Sprite Ordering in Scratch 🐱 | Backpack Depth Sort Tutorial

Поделиться
HTML-код
  • Опубликовано: 24 дек 2024

Комментарии • 1,3 тыс.

  • @Amechaniaa
    @Amechaniaa 3 года назад +172

    Why not use a more efficient sorting algorithm?

    • @griffpatch
      @griffpatch  3 года назад +89

      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.

    • @hriday684
      @hriday684 3 года назад +20

      @@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.

    • @dooplerpoopler
      @dooplerpoopler 3 года назад +5

      @@griffpatch sussy mogus (O3 sus lol

    • @griffpatch
      @griffpatch  3 года назад +13

      @@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

    • @Getoutpl33se
      @Getoutpl33se 3 года назад +3

      @@hriday684 say contextual but replace conte with se and remove the 2nd t”t”

  • @spiritsk88
    @spiritsk88 3 года назад +45

    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!

  • @hakkerkat
    @hakkerkat 3 года назад +294

    I like griffpatch's tutorials because you actually understand them. Unlike the other ones, where you just copy everything.

    • @tankyd8229
      @tankyd8229 3 года назад +23

      Agreed

    • @MrPork-he5lz
      @MrPork-he5lz 3 года назад +11

      @@tankyd8229 True

    • @Supyisiscool
      @Supyisiscool 3 года назад +10

      @@MrPork-he5lz very true

    • @didiervandendaele4036
      @didiervandendaele4036 3 года назад +17

      @@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 !

    • @lincekawaiilindi5422
      @lincekawaiilindi5422 3 года назад +6

      I agree

  • @maplario4366
    @maplario4366 3 года назад +11

    “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.

  • @blueboytube
    @blueboytube 11 месяцев назад +2

    This is one of the best tutorials on the entirety of RUclips

  • @yusong6729
    @yusong6729 3 года назад +23

    This is great! My money was worth it to see these tutorials early! Nice Griffpatch!

    • @TirzaBoi
      @TirzaBoi 3 года назад +2

      8 hours ago?!?! This was posted 2 minutes ago.

    • @MrPuzzleCodes
      @MrPuzzleCodes 3 года назад +4

      @@TirzaBoi thy can see the video early cause of their subscription

    • @TirzaBoi
      @TirzaBoi 3 года назад +2

      @@MrPuzzleCodes oh yeah i forgor ☠️

  • @NeekBot5000
    @NeekBot5000 3 года назад +2

    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.

  • @link8893
    @link8893 Год назад +4

    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.

  • @roggeralves94
    @roggeralves94 11 месяцев назад +1

    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!

  • @ElmoGorilla
    @ElmoGorilla 2 года назад +9

    The great thing with griffpatch's tutorials is that they are easy to learn unlike other people who put in as much as possible.

  • @RealKipper1324
    @RealKipper1324 3 года назад +12

    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!

  • @improvisestudios
    @improvisestudios 3 года назад +10

    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!

  • @InverseOfficial
    @InverseOfficial 3 года назад +10

    The edits during this video look really neat and make this super easy to understand! Great video as always.

  • @janraymond5190
    @janraymond5190 3 года назад +3

    When He Said "The Fun Is Quite Endless" 27:28 I Was Like Majin Sonic LOL

  • @qwertyuiop.lkjhgfdsa
    @qwertyuiop.lkjhgfdsa 3 года назад +2

    I dont know why but a ton of scratch cats bouncing around the screen like the dvd logo was oddly hilarious to me

  • @DexFire1115
    @DexFire1115 3 года назад +6

    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.

  • @ninjinity6684
    @ninjinity6684 3 года назад +14

    "I feel sorry for that chick."
    **Proceeds to delete him from existence*

  • @SLSmartMind
    @SLSmartMind 3 года назад +8

    04:12 AMONG US.
    AWESOME TUTORIAL 😄

  • @totallyapinetree
    @totallyapinetree 3 года назад +6

    THANK YOU SO MUCH FOR THIS! This is the most useful tutorial I’ve ever watched in all of tutorials ever!!

  • @problem7952
    @problem7952 3 года назад +6

    "trees don't tend to walk around" - Griffpatch 2021

  • @vii-ka
    @vii-ka 2 года назад +2

    i made the 1000th comment so that hopefully this video will get recommended to more people it's such a good tutorial

  • @LupinGrossman
    @LupinGrossman 6 месяцев назад +3

    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?

  • @draconia-shadow
    @draconia-shadow 3 года назад +1

    little question how do you get the number of clones and the position of each tings next to the green flags?

  • @FeniteFr
    @FeniteFr 3 года назад +9

    10:19 I love when you do animations to explain how a script work 😸

    • @FeniteFr
      @FeniteFr 3 года назад +2

      @@X-tra_power yes he is strange 😂😂

    • @FeniteFr
      @FeniteFr 3 года назад +2

      @Angus1637 ????? 😂

    • @spiritsk88
      @spiritsk88 3 года назад +1

      4:08 made me appreciate Griffpatch's efforts even more in animating his videos to make it easier to understand.

    • @simplylou8631
      @simplylou8631 3 года назад

      @@spiritsk88 among us

  • @bungsbodulus
    @bungsbodulus 3 года назад

    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

  • @ventisstuff
    @ventisstuff 3 года назад +2

    4:11 best easter egg so far

  • @thunder-hedge
    @thunder-hedge 3 года назад +26

    This is actually very useful, thanks Griffpatch.

  • @freddyfazbear3195
    @freddyfazbear3195 2 года назад +1

    THIS IS PERFECT FOR A HIDE N SEEK GAME!

  • @lukeninja032
    @lukeninja032 3 года назад +15

    I literally trying every single video, keep it up Griffpatch, your tutorials are so helpful

  • @spoopyissad
    @spoopyissad 3 года назад

    This is seriously a thing we all need / needed at one point

  • @Super-qr7wm
    @Super-qr7wm 3 года назад +7

    Can you do a learning ai next?
    If you use lists to keep track of punishments and rewards I'm sure it's possible

    • @m0nt0p23
      @m0nt0p23 2 года назад

      Use cloud for the punishments

    • @3FourFour5
      @3FourFour5 2 года назад

      if we use cloud for punishments there will be an extremely long tangent on cloud lists

  • @mixalispapa4711
    @mixalispapa4711 4 месяца назад

    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.

  • @dazcarrr
    @dazcarrr 3 года назад +6

    this is awesome! top down games are going to look so good thanks to this!

  • @TtEL
    @TtEL 3 года назад +2

    4:50 Yay, finally we get to order some Sprites! I was getting thirsty!

  • @creepersaur
    @creepersaur 3 года назад +16

    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.

    • @griffpatch
      @griffpatch  3 года назад +4

      I used the rotate feature on each layer, but had to move them manually in the X direction to make it look right.

    • @jasondevelopz
      @jasondevelopz 3 года назад +3

      i see a red bean with legs with a blue plate and a backpack

    • @shng8528
      @shng8528 3 года назад +2

      @@jasondevelopz that's an among us character

    • @nikothenoob
      @nikothenoob 3 года назад

      @@shng8528 and that’s what he was talking about

    • @jasondevelopz
      @jasondevelopz 3 года назад +1

      @@shng8528 ik its a joke

  • @FeniteFr
    @FeniteFr 3 года назад +2

    19:13 this is the first time that I have this trick so i'm excited 🔥
    This is awesome 😲

  • @origamiplay1141
    @origamiplay1141 3 года назад +4

    Wow! I am impressed with these best scratch tutorials! Can you also make a hard game from scratch? And keep Scratching!

  • @bigbricks1003
    @bigbricks1003 3 года назад +2

    Probably the only time Griffpatch used a sprite from the Scratch-Sprite Library! Great video griffpatch.

    • @cheesepop7175
      @cheesepop7175 2 года назад

      he used the apple asset in the pathfinding tutorial

  • @Septagon_Sep
    @Septagon_Sep 3 года назад +8

    It's Great! But, When I Click, Things are Just Starting to Get a Bit Lag...

    • @griffpatch
      @griffpatch  3 года назад +4

      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.

    • @Septagon_Sep
      @Septagon_Sep 3 года назад

      @@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.

  • @kaustubhshrestha1265
    @kaustubhshrestha1265 3 года назад +1

    This just gave me an idea that you should make a advanced rpg/adventure game when you have time

  • @idoblenderstuffs
    @idoblenderstuffs 2 года назад +3

    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.

    • @Funni_Stuff
      @Funni_Stuff 7 месяцев назад +1

      You found out yet?

    • @idoblenderstuffs
      @idoblenderstuffs 7 месяцев назад +2

      @@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.

    • @Funni_Stuff
      @Funni_Stuff 7 месяцев назад +1

      ​@@idoblenderstuffs Nice job learning unity!

    • @Alex-is-Procrastinating
      @Alex-is-Procrastinating 2 месяца назад +1

      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

  • @sirblueberrous146
    @sirblueberrous146 11 месяцев назад

    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!

  • @Blue-gy2it
    @Blue-gy2it 3 года назад +4

    4:13 AMONG US

  • @_-cyber_
    @_-cyber_ 2 года назад +2

    Would adding scrolling make this effect unusable?

  • @oscarhuang8732
    @oscarhuang8732 3 года назад +4

    you put appel and lemons but now u put among us WHY AaAaAaAaAaAaAaAaAaAaAaAaAaAa

  • @Speed-TV
    @Speed-TV 2 года назад +1

    24:35 Everything is good until you notice the black dot in the top right of the stage

  • @IkeIllich
    @IkeIllich 2 месяца назад

    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!)

  • @milankarow6567
    @milankarow6567 3 года назад +2

    Awesome tutorial! Hope to put it to use some time soon...

  • @Sharp2006
    @Sharp2006 3 года назад +1

    Griffpatch makes me look forward to the start of the week : )

  • @MINTGREENYT369
    @MINTGREENYT369 2 года назад +1

    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

  • @ekeefx
    @ekeefx 2 года назад +1

    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.

    • @apple_ilev5s
      @apple_ilev5s 2 года назад

      i think the only way to do it is with complicated math, so either figure it out yourself, or wait for griffpatch

  • @cjgamesstudios3289
    @cjgamesstudios3289 2 года назад +1

    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

  • @gamingaiden7680
    @gamingaiden7680 3 года назад +1

    1:27 why is appel there

  • @-epicool-
    @-epicool- 3 года назад +1

    you are the best teacher in the entire world

  • @megatron4507
    @megatron4507 2 года назад +1

    Omg!!! This is perfect for my game!!!!! 🤩🤩🤩 THANK YOU GRIFFPATCH!!!!! YOU'RE THE BEST!!!!!

  • @jazzling
    @jazzling 2 года назад +1

    so helpful, I made a 3d gravity simulation with this, thank you!

  • @CBFNetworksArchive
    @CBFNetworksArchive Год назад

    Nano finally got a smile on his face! (This is his world, not that scary Raycaster!)

  • @impressivesmirk
    @impressivesmirk Год назад

    Griffpatch, you are a genius!

  • @theopoldthegamer4284
    @theopoldthegamer4284 7 месяцев назад

    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

  • @RalphyTheCoyote
    @RalphyTheCoyote 2 года назад +1

    I’m working on an RPG rn (not ur rpg) and I can’t seem to figure out the permanent sprite layering trick.

    • @griffpatch
      @griffpatch  2 года назад +1

      It's permanent because we stamp layer 3 last, which is the only layer that appears above the player.

    • @RalphyTheCoyote
      @RalphyTheCoyote 2 года назад +1

      @@griffpatch May I share the project to u?

    • @RalphyTheCoyote
      @RalphyTheCoyote 2 года назад +1

      and u take a look

  • @jahazielalicea8359
    @jahazielalicea8359 3 года назад +1

    in 4:12 there is among us in a part can you find it?

  • @bluedragooo
    @bluedragooo Год назад +1

    Thanks! This really helped me learn!

  • @ZaniSquad
    @ZaniSquad 3 года назад +1

    You are a excellent Coder

  • @tdub1776
    @tdub1776 3 года назад +2

    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!

  • @DylanTheEye
    @DylanTheEye 2 года назад

    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

  • @double9videos
    @double9videos 2 года назад

    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

    • @griffpatch
      @griffpatch  2 года назад

      Absolutely, so useful right

  • @brandonseupersad7916
    @brandonseupersad7916 3 года назад

    I'm going to use what I learned from this video to layer the towers and enemies in my tower defence project.

  • @beehivemind9343
    @beehivemind9343 3 года назад

    finally, i've been wanting this for a while

  • @emilyy03
    @emilyy03 3 года назад +1

    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!

  • @AshSomera
    @AshSomera Год назад

    Griffpatch's Videos Are Awesome! Bro!

  • @tezereth
    @tezereth 3 года назад

    This is literally what I needed

  • @grandestag
    @grandestag 3 года назад

    I don't get tired of saying this but all your tutorials are very useful

  • @hussin_-ws7bc
    @hussin_-ws7bc 3 года назад +1

    hi griffpatch can you make a tutorial titled how to make a cloud list pls

  • @dunnomynameso746
    @dunnomynameso746 2 года назад +1

    4:12 damm bro griffpatch be a lil humorous

  • @easylemon6640
    @easylemon6640 Год назад

    Thanks! This was really useful for my isometric Minecraft: Scratch Edition project I'm working on!

  • @MJJAofficial
    @MJJAofficial 3 года назад +1

    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?

  • @FeniteFr
    @FeniteFr 3 года назад +1

    18:05 Haha thank you griffpatch ❤️✨

  • @Nuttygamer27
    @Nuttygamer27 3 года назад

    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

  • @Structed-2
    @Structed-2 10 месяцев назад

    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

  • @supersmashbrosforscratch8762
    @supersmashbrosforscratch8762 2 года назад

    Thanks Griffpatch! you're the best Scratcher!

  • @TheActualFBI.
    @TheActualFBI. Год назад +1

    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

  • @ozgort990
    @ozgort990 2 года назад

    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

  • @Twin138956Productions2019
    @Twin138956Productions2019 3 года назад +1

    That was a great tutorial. :)

  • @Whoevenisdeltalikewhat
    @Whoevenisdeltalikewhat 7 месяцев назад

    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!

  • @juliocesarcamilo5132
    @juliocesarcamilo5132 7 месяцев назад

    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?

  • @KnitnStyle432
    @KnitnStyle432 Год назад +1

    Very useful!

  • @jameswoodcock485
    @jameswoodcock485 3 года назад

    Yes! Great video Griffpatch!
    And of course - chickens for the win. That got me.

  • @Taelo
    @Taelo 3 года назад

    griffpatch back at it with the banger videos

  • @JATTheScratcher
    @JATTheScratcher 2 года назад +2

    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! )

  • @itshatee
    @itshatee 3 года назад

    griffpatch: 28:53 "all alone and not moving any where, i feel sorry for it"
    proceeds to hide it from existents

  • @Danceunf
    @Danceunf 3 года назад

    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

  • @luoyimin7911
    @luoyimin7911 11 месяцев назад

    Is it possible to set the layer where each sprite is located to the opposite number of its y-coordinate

  • @SamFromSpaceOfficial
    @SamFromSpaceOfficial 3 года назад +1

    Thank you so much Griffpatch! I needed sprite sorting for my new platformer and this has helped out a ton!

  • @archusrtm6325
    @archusrtm6325 3 года назад

    This is exactly what I was looking for

  • @ninan-9196
    @ninan-9196 3 года назад

    I'm having as much fun with this as you griffpatch! Thanks!

  • @thetitantacos7126
    @thetitantacos7126 3 года назад +1

    This is really useful, I've always wanted this. (also I saw something sus at 4:13 )

  • @jaimerodgen3433
    @jaimerodgen3433 8 месяцев назад

    Do you think you can add collision with the cat and tree ?

  • @the_real_twentytwentythree
    @the_real_twentytwentythree Год назад

    This Goes Great with Z Position!

  • @someguy9072
    @someguy9072 2 года назад

    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

  • @sheryvp1
    @sheryvp1 3 года назад +1

    Awsome!! This Is Very Useful Thanks!!