Hey guys what’s up it’s the crazy Dev here back with another video um yeah it’s the first time I apologize um I posted the last one seven months ago I didn’t realize it’s been that long um I’ve just been doing a lot of stuff um next to that Um yeah the research to this okay so first things first I want to first off make this better neater because there’s a few things in here I that did were completely pointless and then we’re gonna also show you guys how to make up be able to save chunks You load and be able to load those in which will also eventually allow you to do scrolling with your things um but that’s not good results okay so first things first um let’s neaten this up and fix it so first thing let’s just come down here to our road Gen height now if you don’t have any of this code here go watch my last video explained how to code all this and I explained what everything does here first things first so go to your Rogen with the height um custom block come down bottom and I Don’t know who but somebody pointed this out in my last video I used a repeat one here which is completely pointless so I’m just gonna get rid of this repeat one and just do it like that so yeah that’s that’ll yeah this is completely pointless there’s no point of doing a repeat one There so remove that now one more thing I did I created a whole new custom block just so I can repeat this block which is kind of it’s pointless so we can do instead is just come to edit here and we can just add one more input called X rows And we can just basically okay um let’s see yeah we can just straight up come like this um we think here okay so what we can do is we can grab this repeat X rows from up here or describe repeat I’ll just get rid of this whole 10 terrain generating thing Here let’s delete this terrain generator okay hold on okay see it’s the strip the elite the terrain generate Block it’s completely pointless there’s no point in that okay so now let’s grab a repeat here and put it around this whole the fine thing and we’re going to define a repeat X rows And let’s see here what else I don’t think this will work automatically so what we’ll do is instead of doing a height here we can remove this height block and what we can do is we can create a variable I don’t know why these variables are here still like this create variable What is this okay okay whatever so make a variable and we’re going to call it height you can insert to this for the spray only because don’t mind yet for anything else so we’re gonna repeat height so what we can do here so we can go set each timer repeat X rows We can go um all right we’re gonna set height above this show we’re going to set height equal to pick random between your height which well for me I think is six and seven and now we should just be able to run adjust this row gen We can enter in how many rows you want and it’s not working oh yeah because I gotta swap get rid of this height and this repeat right here the very top well version is repeat height minus three we’re gonna actually replace that with height for our variable Now we can just click the screen fog and we got terrain generation again so yeah boom that was that extra custom block was completely pointless and that will probably save some processing I guess because you know a lot of times if you have tons of custom blocks your projects Start to get laggy so that’ll definitely help yes break this down so yeah that helps a lot so with that gone we can begin working on the loading and saving okay so first things first let’s go to variables here and come to our make your list button and let’s create a list Called Terrain uh you can do for all Sprites you might want to build graxes so yeah what we’re going to do is go Terrain and what we’re going to do is we’re going to use a method of storing our x and y basically the storing values or it tends About multiple values inside of one variable or value type thing um so basically let me show you what we do so what we do okay so to store I’ll say we store our X position and Y position in one variable okay so I could say we want to just Build axis one variable and get all these now suddenly um scratch doesn’t have Vector twos or vector threes if you don’t know what it is it’s fine but basically um we can’t like so we try you might have thought okay we can just join these together and just mix up that equal to But X position so it’s bam like that it’s okay now we have 241 16 0 and what we can do is you can just grab one two and three for exposition well the problem is let’s say our variable here or our block goes to 2 or I’ll say like a two digit number Yeah okay so we have a two digit X in three digit y well now it’s this so we’d have to grab the first two numbers so this to grab our X but if oh so now I’m three digits now I also go to the three So you never know so what we do is when we add these together we add 500 to them or whatever value depending on how big your X position or value might get you’re going to add that much so add 500. and as you can see now And then when we need our x position we can now always grab the one three because being that um scratch is fencing and you can’t get off the screen your X and Y will never be greater than three so if we set it equal to 500 All we have to do is subtract 500 and then bam we instantly get our X position no matter where we are so this is how we store it and then we just need to grab the first three letters in this uh six seventh and eighth numbers for our y position So that’s how we store values in one variable so that’s the method we’re using I just thought I’d explain this because I use a ton um this is also especially handy for online multiplayer um so yeah okay so first things first we can actually um I’ll get rid of this we Can restart so let’s grab my variables come to variables here and let’s grab an add thing to terrain okay and we’re going to come over here and we’re going to go grab a join I grew up two of them actually I’m gonna put a Joy inside of a join Because what we need to be able to grab it is when we generate our terrain our loader train we need to know what costumes to wear which puts X and Y position is where I mean you either regenerate that terrain because that’s the only thing that’s really changing we don’t have any other Type of stuff that changes varying on their stuff so so here we’re just gonna send over or make our X and Y in costume that I guess so inside of this first join we’re going to go join X position plus 500. and you can actually duplicate this Like twice because we’re going to need a center versus so and then second one go y position basically we’re gonna join X position plus 500 with Y position plus 500 with our costume number Plus 500. and then put this inside of our add thing to terrain so now We have a block that’ll add our positions and costume numbers inside of one thing over so now we can do is here every time we create a column myself we originally generate this Terrain we can just go like this now you could actually completely remove the create clones of myself which I get yeah we’ll actually do that because that’ll be a lot easier for testing so we’re gonna remove these create clones of myself and put the change right back in bam change y and create calling myself here we remove that and Bam so what we need to do now is Duplicate this three times inside of our repeat height up here okay where we moved all the Clones we need to add in our position or add in this block so bam now make sure to put above before we change Y in all these or else we will get the wrong Position on each one so come here to this one but above chain Y and repeat two and then come above this change by 32. and paste it there nice okay so now we have that now if you pull up our list here um also one more thing make sure to Delete all of terrain when we call Rogen so now if I pop Terrain at high if I pulled Terrain as you see as I click this this thing’s changing now obviously the top few variables aren’t really changing because those will always probably be the same like The same type of numbers and stuff but as you can see if you look at the length right here you can see that it’s changing as we click this so basically we’re generating new terrain each time we click this button which is absolutely sick I’m also going to grab this go-to thing because Um our characters can not gonna start the right place so go bam so we can remove this whole random green that from the one green buck load um if you wanted to make this even better you could create some extra inputs in here for your starting exposition to generate The train and add them to this go-to but for now I’m just gonna have it so I always generate it there okay so now we have this where we can generate terrain every time we call this progen um like so which is really cool but as you Can see we don’t have a Terrain I mean we can’t see anything there’s just just values so what we need to do now is basically go into this list and grab our position our Exposition y position and costume go to the position and then swap to that costume and create a clone So or go like this so when um no it will create a new block her new block and call it load terrain and I don’t think we need any inputs but do make it run without screen refresh unless you want like a loading type of terrain but that’ll take ages Okay so with the load terrain here we need to go like this so first things first let’s grab a repeat so let’s grab repeat and we’re going to repeat the length of our Terrain um yeah repeat length of terrain so we can basically Loop through every single item and Terrain And what we’ll do now is we’ll go let’s see here um oh yeah okay so what we’ll do is we’ll go set X2 and what we’ll do is we’ll set x equal okay now this this Block’s gonna get kind of longer we’re going to grab two Joins or yeah grab two joints we can join three items together and grab three letters of insert them in each of these joined apples or bananas to other ones so I guess they should have join letter one of apple with join um so join letter one of Apple With a join letter one of Apple to join it with a letter one available so basically this will give us three A’s if you didn’t change in these values or three I don’t know anyways what we’ll do now is instead of Apple we’re gonna give item one of terrain Okay and what we need to do is here at letter one letter two and letter three of terrain as you can see this would give us the value so if we pull up terrain here it grabs it gives us 273. um yeah so 273 now this we can’t just grab This data automatically this is not our X position because remember we added 500 so our X Position will constantly be a three digit value we need to subtract 500 from it so by subtracting 500 from it it gives us our X position which is negative 224. so now we can actually duplicate this Three times because we’ve got to grab our Y and our costume number and I’m going to search this in set X2 and I’m going to need to grab a set y I said y I didn’t insert another one in and then we’re going to go uh where is it switch costume two and Then put this one inside of that and now if we come here okay we’re going to change this letter okay so or in the set wiser and set y we need to change this to letter four five and six or whatever order you made this so Right here we put the X position in my position then costume number and you need to do it in that word on here so and we added 500 now if you were do like turbo warp or something your Exposition could get greater than like three digit Values you’re gonna have to add like a thousand or five thousand um so yeah if you guys want me making a whole video and explaining just these because these things are super handy um let me know in the comments but I’m gonna repeat Klein this train Whatever and what we need to do is once we do all this oh yeah one more thing with this train down here we need to grab it so for the costume we need to grab letters seven eight and nine there we go so now our character will go to The X and Y and so is your costume to the right costume then we need to create a clone of myself nice and we Cosmic message here so each and front broadcast clear so grab a broadcast and make it a clear so we’ll broadcast clear and when I receive clear Delete this column so basically we’ll clear all the Clones when you run this just in case we have or your run Ransom load train or whatever now one more thing we can do is we can act um or not one more thing but we have to do this we need to delete Item one of terrain so now okay now this should automatically work so if I let’s come over here grab Rogen generate some new Terrain then grab load Terrain click it and we forgot to do one thing now there is clones right here but you can’t see Them because we forgot the at the end of this code we hide our character or our terrain generator so what we need to do is we just need to make it so we show when we start this and hide when we end so now if we generate some terrain here So generate some new Terrain load that terrain and boom we’ve generated train now the one thing with what we currently have is all your terrain gets deleted now that’s easy fix um you could just leave it like this I didn’t put this in yet because I didn’t Know if if you guys want it to do it your terrain or your whole train list so you can never generate it again it’s fine but you could well all you really need to do is just go add before this delete one of three so you’ll create clone myself and we’re gonna add Item one of terrain two terrain and then we delete item one of terrain so now via Rogen low Terrain as you can see this didn’t change so I’m trying some new Terrain hit low so it’s 99 and if I load the terrain we’re gonna get new terrain yet The length of our list is going to stay at 99. and you can watch this Top Value and see that doesn’t change so as you can see we can generate a new terrain and it’s allows us to generate new terrain while keeping this terrain list so that’s awesome And then ultimately you could make this for a saving system all you’d have to do is like divide it basically you could save your whole terrain list and then when you come back to save it you can just divide each item by nine uh I’ll make more videos on that but Anyways guys um that’s really all for this thing it’s a pretty simple not too long even though my video is about 16 minutes um yeah I don’t know it’s pretty it’s pretty easy and it’s very handy this is done very nice and again if you just Want to make it like how you used to you can just run the Rogen and load terrain together so yeah but that’s that’s it that’s pretty simple if you guys have any questions about the thing or if I was going too fast let me know in the comments down below and if You guys have any more um stuff you want me to do with this terrain generator uh let me know in the comments because that’d be happy to answer them uh but yeah that’s all for this video and see you guys next time Video Information
This video, titled ‘Scratch | Minecraft Random Terrain Generator PART 2’, was uploaded by TheKrazyDev on 2022-11-15 21:15:00. It has garnered 751 views and 21 likes. The duration of the video is 00:17:34 or 1054 seconds.
Hey guys welcome back to part 2 on the Random Terrain generator. Sorry it took so long to post. Ive been busy learning languages like java and python so Ive bean busy. Hopefully more vids soon!
#Scratch #Programing