 Hello world, it's the surfing scratcher here bringing you another video connecting the world of scratch to maths If you haven't already checked the description below for links to previous videos as this one is part of a series in this video We'll explore the expanded notation part of our space value game So that means when objects pop around the screen. We need to be updating the variables down the bottom So let's get stuck into it. Okay, here. We are back in our scratch project for space value the level five six addition You will recall that we left our last video with the broken game So if I press this green flag here, and I start popping all these space objects You'll notice that dang all of our place values here are not updating and nor is our squirrel in the top left Tank corner. So let's stop that and let's investigate why that's actually happening So we're going to be starting with our tense planet today. So we what do we know? We know that when we pop planets, we expect the tense to update because that's what a planet is worth So I'm going to click on the 10th sprite and we're going to inspect that code We know that when the green flag is clicked we just hide it because we don't want them on the stage So that's cool. I've got this code here that when it starts as a clone It picks around a position it shows it and then it waits Some delay and then it gets deleted. So that's not what we actually look for We're looking for the code for when it's clicked and that happens right here So when this sprite is clicked, that's the tense planet sprite. We play that pops down Yep, that happens. We hide it and then we broadcast the message tense popped and then we delete it So sounds seems like this would be a great place to pop our code We're not going to pop it directly inside here We're going to pop it in a more central spot where we can handle all the values all of our place value scores So we're going to be doing that in our place value sprite All of them the beauty of having a broadcasted message is that whoever is receiving that message will be able to handle it Awesome. So before we get stuck into our code What I like to do is I like to plan out what I'm going to be doing So I'm going to jump across into my scratch planner that I use to help me. So you'll see here that we've got the stage Set up and I'm just going to reveal a couple more things down here So we've got our sprites. We've got our variables and we've also got some scripts now What I like to do is I like to create English sentences first and that helps me Figure out my own words what I want the program to do and then I can use this as a starting point to translate it into scratch blocks So let's do that. Let's start at the top here. It says that when the tense planet is clicked change the tense score by Well, yeah, we need to change it by a tenth. So every time it's clicked We know that the tense update by a tenth. Well, that looks like a terrible tent there There we go. That one's a little bit more visible, but something happens when we have ten of something So we need to tell the game what to do when that happens. That's right So if you've got ten pence, that's a special thing in place value So if there are ten tense So if there are ten tense, then we need to regroup to a Which way would you regroup it to? Well, we know that in the place value that when we're adding things we're actually increasing Places are our collections. So when we have ten tense, that's the same thing as one unit So we need to regroup to a unit And once we do that. Well, we're going to be pushing ten of those tents across the here So we've got a unit, but then we don't want ten pence in here anymore. We need to reset that back to zero Okay, so and then we set the tense back to zero Great. So this is like our English sentence that we sentences that we need And now all we need to do is translate this into some scratch box So let's just again start at the top and see if we can find some stuff related to Scratch so when the tense planet is clicked Well, we know where that's located that's inside the actual sprite object Then we need to change the tent score by one. So let's go back across We need to now Receive that event. So we're going to go across to our vents and we're going to grab a receiving block And we don't want to know when our hundred's popped just yet. We're focusing on our tents And then they are right there. So we're on our tents block Let's go back to our plan. So we need to change the tent score by one So I know where one of those blocks is located. We're changing the variable tents because this is our tents variable here There's right there and we need to look at that beautiful. There is a change block right there for us to use We don't need to change the game time seconds. We want to change our tents by a 10th. Okay, so we're changing our tents by 10th now if I press that You will see that our tents is actually updating which is pretty awesome if I press this one It will also update. So we know that that piece of code is actually working now, which is wonderful. Let's get back to our plan Something happens when we have 10 something cool. So we'll skip that that little part there So if there are 10 of something now if is a great word to be using when we're coming out with English sentences Because it sort of says to our program that we need to make a decision if something happens Then we want we want to perform this action. Otherwise do this. So if there are 10 tents Okay, now what I like to do for this particular one is instead of using an equal to block I'm actually going to use a greater than symbol because scratch is a little bit buggy at the moment with the new version that's just been released and Sometimes it can skip over When our 10 tents is equal to one. So we're just going to account for the condition When our tents are greater than nine tents. I'll show you what that looks like in a second. So if our tents So let's just let's just do it in that order. So if our tents are Greater than nine tents. So we need a greater than operator There we go. You know that the open area points the larger Part with a larger side. So our tents are greater than nine tents great So if our tents are greater than nine tents well What were we doing with that? We were Regrouping to a unit. So I know that we have we're going to we've got all these nice events here when I receive tents popped Well, the nice thing that we can do is we can just broadcast a new event And we're going to create a very similar block for our units So why not just say the event our unit popped? Okay, we'll change all this stuff for our units So now we've regrouped to a unit and then we need to set the tents back to zero Cool. So that one's pretty easy. There is a set block back in our variables. We'll grab that again We need to change it back to our tents and look it's already preset there for us So if I click this when we get to beyond nine tenths or seven tenths now, you can see that there's eight tenths There's nine tenths. I would expect this to go back to zero and then we should have a unit. Let's have a look Okay, cool. So we went back to zero But of course we don't have a unit yet because we are not handling for our units So let's actually do that right now. The way that we can do that is just right click on this code block and Duplicate it because we've done all the heavy lifting right now So we no longer want to know when our tents are popped because if we left this we would just be getting Tents every time our our planets were clicked So now we want to know when our unit is popped and we're no longer changing our tents when our unit is popped We need to change our units Not changing them by a tenth or changing them by a unit or the one if our well no longer tense if our units are Greater than well, we're just shifting up place values aren't we if our units are greater than nine? Well, we know that we regroup that to a Ten and we don't have a message for that one so you could go ahead and create it So you could go ahead and say our ten popped Yeah, that doesn't exist. We don't have our tens, but that's what we would do if we wanted to handle it now We need to go through and reset our units back to zero So let's go see I'm going to click up to ten tenths now and hopefully we'll get a unit one two three four five six seven eight nine tenths and Boom great. You see that we went back to zero and then we included our unit We just regrouped ten tenths to one unit Okay, so my scratching is actually over for this project I'm gonna leave it to you to code the hundreds and the thousands because I reckon you'll be able to do that based on what is already here Don't forget that you can duplicate these code blocks. Good luck. That's all for this video in the next one We're gonna be exploring connecting the expand notation to the score and in the top left hand corner of our screen If you like this video give it a thumbs up and if you want to stay connected to when I release more content Make sure you hit that subscribe button, but until then I'm off to go find a way. Take it easy