Perfect Sprite Ordering in Scratch 🐱 | Backpack Depth Sort Tutorial

Поділитися
Вставка
  • Опубліковано 15 вер 2024

КОМЕНТАРІ • 1,3 тис.

  • @VY_Canis_Majoris
    @VY_Canis_Majoris 2 роки тому +169

    Why not use a more efficient sorting algorithm?

    • @griffpatch
      @griffpatch  2 роки тому +88

      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 2 роки тому +19

      @@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 2 роки тому +5

      @@griffpatch sussy mogus (O3 sus lol

    • @griffpatch
      @griffpatch  2 роки тому +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 2 роки тому +3

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

  • @hakkerkat
    @hakkerkat 2 роки тому +286

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

    • @tankyd8229
      @tankyd8229 2 роки тому +21

      Agreed

    • @MrPork-he5lz
      @MrPork-he5lz 2 роки тому +10

      @@tankyd8229 True

    • @Supyisiscool
      @Supyisiscool 2 роки тому +9

      @@MrPork-he5lz very true

    • @didiervandendaele4036
      @didiervandendaele4036 2 роки тому +16

      @@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 2 роки тому +5

      I agree

  • @spiritsk88
    @spiritsk88 2 роки тому +46

    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!

  • @maplario4366
    @maplario4366 2 роки тому +10

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

  • @RealKipper1324
    @RealKipper1324 2 роки тому +11

    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!

  • @yusong6729
    @yusong6729 2 роки тому +22

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

    • @TirzaBoi
      @TirzaBoi 2 роки тому +2

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

    • @MrPuzzleCodes
      @MrPuzzleCodes 2 роки тому +4

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

    • @TirzaBoi
      @TirzaBoi 2 роки тому +2

      @@MrPuzzleCodes oh yeah i forgor ☠️

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

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

  • @improvisestudios
    @improvisestudios 2 роки тому +9

    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!

  • @SLSmartMind
    @SLSmartMind 2 роки тому +8

    04:12 AMONG US.
    AWESOME TUTORIAL 😄

  • @roggeralves94
    @roggeralves94 8 місяців тому +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!

  • @InverseOfficial
    @InverseOfficial 2 роки тому +10

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

  • @blueboytube
    @blueboytube 8 місяців тому +2

    This is one of the best tutorials on the entirety of UA-cam

  • @totallyapinetree
    @totallyapinetree 2 роки тому +6

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

  • @NeekBot5000
    @NeekBot5000 2 роки тому +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.

  • @ninjinity6684
    @ninjinity6684 2 роки тому +12

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

  • @janraymond5190
    @janraymond5190 2 роки тому +2

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

  • @thunder-hedge
    @thunder-hedge 2 роки тому +26

    This is actually very useful, thanks Griffpatch.

  • @FeniteFr
    @FeniteFr 2 роки тому +8

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

    • @FeniteFr
      @FeniteFr 2 роки тому +2

      @@X-tra_power yes he is strange 😂😂

    • @FeniteFr
      @FeniteFr 2 роки тому +2

      @Angus1637 ????? 😂

    • @spiritsk88
      @spiritsk88 2 роки тому +1

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

    • @simplylou8631
      @simplylou8631 2 роки тому

      @@spiritsk88 among us

  • @lukeninja032
    @lukeninja032 2 роки тому +15

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

  • @bungsbodulus
    @bungsbodulus 2 роки тому

    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

  • @problem7952
    @problem7952 2 роки тому +6

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

  • @DexFire1115
    @DexFire1115 2 роки тому +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.

  • @LupinGrossman
    @LupinGrossman 3 місяці тому +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?

  • @TtEL
    @TtEL 2 роки тому +2

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

  • @crackerpooppop
    @crackerpooppop 2 роки тому +4

    im definitely using this on my game im working on, ive been scratching my head for months trying to figure out a good solution to layer glitches i keep having!

  • @bigbricks1003
    @bigbricks1003 2 роки тому +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

  • @dazcarrr
    @dazcarrr 2 роки тому +6

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

  • @CBFNetworksArchive
    @CBFNetworksArchive Рік тому

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

  • @origamiplay1141
    @origamiplay1141 2 роки тому +4

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

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

  • @idoblenderstuffs
    @idoblenderstuffs Рік тому +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 4 місяці тому +1

      You found out yet?

    • @idoblenderstuffs
      @idoblenderstuffs 4 місяці тому +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 4 місяці тому +1

      ​@@idoblenderstuffs Nice job learning unity!

  • @megatron4507
    @megatron4507 Рік тому +1

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

  • @Septagon_Sep
    @Septagon_Sep 2 роки тому +8

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

    • @griffpatch
      @griffpatch  2 роки тому +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 2 роки тому

      @@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 2 роки тому +1

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

  • @Super-qr7wm
    @Super-qr7wm 2 роки тому +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

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

  • @Sharp2006
    @Sharp2006 2 роки тому +1

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

  • @creepersaur
    @creepersaur 2 роки тому +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  2 роки тому +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 2 роки тому +3

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

    • @shng8528
      @shng8528 2 роки тому +2

      @@jasondevelopz that's an among us character

    • @nikothenoob
      @nikothenoob 2 роки тому

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

    • @jasondevelopz
      @jasondevelopz 2 роки тому +1

      @@shng8528 ik its a joke

  • @FeniteFr
    @FeniteFr 2 роки тому +2

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

  • @Blue-gy2it
    @Blue-gy2it 2 роки тому +4

    4:13 AMONG US

  • @qwertyuiop.lkjhgfdsa
    @qwertyuiop.lkjhgfdsa 2 роки тому +1

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

  • @oscarhuang8732
    @oscarhuang8732 2 роки тому +3

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

  • @spoopyissad
    @spoopyissad 2 роки тому

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

  • @-epicool-
    @-epicool- 2 роки тому +1

    you are the best teacher in the entire world

  • @itshatee
    @itshatee 2 роки тому

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

  • @tdub1776
    @tdub1776 2 роки тому +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!

  • @sirblueberrous146
    @sirblueberrous146 8 місяців тому

    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!

  • @ventisstuff
    @ventisstuff 2 роки тому +2

    4:11 best easter egg so far

  • @milankarow6567
    @milankarow6567 2 роки тому +2

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

  • @jameswoodcock485
    @jameswoodcock485 2 роки тому

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

  • @jazzling
    @jazzling Рік тому +1

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

  • @freddyfazbear3195
    @freddyfazbear3195 Рік тому +1

    THIS IS PERFECT FOR A HIDE N SEEK GAME!

  • @MINTGREENYT369
    @MINTGREENYT369 Рік тому +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

  • @Damageer
    @Damageer 2 роки тому +2

    I needed this for so many of my projects, wish i knew this sooner.. it would’ve saved so many hours trying to get the layers perfect 😅

  • @LilyPillow
    @LilyPillow 2 роки тому +2

    Thanks, this was useful! Also you’re so close to 100k! You can do this, you’ll be able to get the silver creator awards and get verified! 😃

  • @blenderfox_foxwastaken
    @blenderfox_foxwastaken 2 роки тому

    4:11 Nice video! I love how the little red Among Us character is peeking out the edge. Red sus

  • @thetitantacos7126
    @thetitantacos7126 2 роки тому +1

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

  • @tabletgenesis3439
    @tabletgenesis3439 2 роки тому +1

    When I click on the video: bruh cloning sprites is easy
    When he says they are ordered back to front: *insert thinking emoji*
    When he shows behind the trees: GOD CODING

  • @darealelohim
    @darealelohim Рік тому

    22:52 When you're trying to get through a crowd during a football game XD

  • @grandestag
    @grandestag 2 роки тому

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

  • @AshSomera
    @AshSomera Рік тому

    Griffpatch's Videos Are Awesome! Bro!

  • @SamFromSpaceOfficial
    @SamFromSpaceOfficial 2 роки тому +1

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

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

  • @supersmashbrosforscratch8762
    @supersmashbrosforscratch8762 2 роки тому

    Thanks Griffpatch! you're the best Scratcher!

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

  • @brandonseupersad7916
    @brandonseupersad7916 2 роки тому

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

  • @emilyy03
    @emilyy03 2 роки тому +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!

  • @bluedragooo
    @bluedragooo Рік тому +1

    Thanks! This really helped me learn!

  • @easylemon6640
    @easylemon6640 Рік тому

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

  • @biolumen_
    @biolumen_ 2 роки тому +1

    I cant stop playing taco burp it’s amazing!!!!! Although there was this one player who literally spawn killed me, apart from that the game was awesome 👏

    • @ninan-9196
      @ninan-9196 2 роки тому

      oh god that player's greed

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

  • @mixalispapa4711
    @mixalispapa4711 Місяць тому

    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.

  • @sagnikmukherjee2312
    @sagnikmukherjee2312 2 роки тому

    I really wanted such a tutorial for my zombie game! Thanks thanks thanks Griffpatch!!! 😁😁😁😁😃😃😃😃

  • @dylanfromwhoville
    @dylanfromwhoville 2 роки тому

    My brain can't handle all of this knowledge.

  • @draconia-shadow
    @draconia-shadow 2 роки тому +1

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

  • @ellayin0406
    @ellayin0406 10 місяців тому

    Hey griffpatch! I have found a way to make it instant, you dont want that cat appearing out of nowhere? Use blocks! Make a block called clone or somthing else, attach it to under the set size to 150 block but remember to take out the blocks below the set size to 150 first then put the block, now put the blocks you just pulled out of, and attach it to the define, not that the block MUST BE WITHOUT SCREEN REFRESH yet it makes a istant meaning instant layering! Now you wont have to need to wait

  • @ChocolatBs
    @ChocolatBs 2 роки тому

    Thank you so much ! You helped the beginning of my project

  • @impressivesmirk
    @impressivesmirk Рік тому

    Griffpatch, you are a genius!

  • @theopoldthegamer4284
    @theopoldthegamer4284 3 місяці тому

    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

  • @FunkyPupo
    @FunkyPupo 2 роки тому

    Griffpatch, I love your videos! Keep going! Also, I'm wondering if you are doing a Q&A. If you are, great!

  • @the_real_twentytwentythree
    @the_real_twentytwentythree 9 місяців тому

    This Goes Great with Z Position!

  • @sheryvp1
    @sheryvp1 2 роки тому +1

    Awsome!! This Is Very Useful Thanks!!

  • @juliocesarcamilo5132
    @juliocesarcamilo5132 3 місяці тому

    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?

  • @haywiressc2608
    @haywiressc2608 2 роки тому +1

    really usefull! definatly gonna rtemember this haha

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

  • @zippycat
    @zippycat 2 роки тому

    wow thank you! i needed this for my multiplayer game!

  • @WorstedCorgi90
    @WorstedCorgi90 2 роки тому

    I was making an rpg style game, this is just what it needed thank you griffpatch!

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

  • @archusrtm6325
    @archusrtm6325 2 роки тому

    This is exactly what I was looking for

  • @ZaniSquad
    @ZaniSquad 2 роки тому +1

    You are a excellent Coder

  • @Taelo
    @Taelo 2 роки тому

    griffpatch back at it with the banger videos

  • @muhammedsaleel3749
    @muhammedsaleel3749 2 роки тому +1

    There's something hilarious about a person calling a chicken 'they'. This kept cracking me up lol!

  • @th1v5
    @th1v5 2 роки тому

    I use a simple script (made before watching)
    Set Current layer to 0
    FOREVER:
    Go backward current layer layers
    Go forward New Layer layers
    Set New Layer to (whatever)
    Close FOREVER

  • @FeniteFr
    @FeniteFr 2 роки тому +1

    18:05 Haha thank you griffpatch ❤️✨

  • @Twin138956Productions2019
    @Twin138956Productions2019 2 роки тому +1

    That was a great tutorial. :)

  • @ExtemTheHedgehogLol
    @ExtemTheHedgehogLol 2 роки тому

    Bro this is awesome! I can’t wait for the next o- *wait it’s not monday*

  • @gunjantutorial7405
    @gunjantutorial7405 2 роки тому

    Wow sprite depth sorting! This will help me in many ways for creating 3d games!!

  • @yannismorris4772
    @yannismorris4772 2 роки тому

    This video will be outstandingly essential to one of my game ideas.
    (And it's given me another idea, too.)

  • @St.Sogofhedgehogs
    @St.Sogofhedgehogs 2 роки тому

    For some reason, I couldn't comment and see comments but that's fixed now.
    love your vids!! (you remember me?)