 Hello world, it's the surfing scratcher here bringing you another video connecting the world of scratch to maths 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're going to be taking the plan that we hatched for our safe move type block and Translating our English sentences into scratch blocks. So get yourself comfy and let's get stuck into it Okay, so here we are back in our scratch project and I'm still in the card sprite I'm just gonna shift across to the bat Great. Okay. So what you'll need to do is Navigate to the place inside the bat where you can find safe move type There will be one of these like little save blocks connected to it You need to delete that because we need a fresh copy of it right here Okay, so hopefully you've gone ahead and watched the previous planning video because we're gonna go ahead now and Enter in the blocks of code that we need we're gonna do a direct translation so across here you can see that I've got my Planner my scratch planner here and we're gonna be taking each of these blocks of English code and Translating them into these scratch blocks. So let's start from the top if the variable Operation is equal to the addition symbol. Okay. Now. I use the I say addition and positive in the context of this operation interchangeably, so I'm sorry if that bugs you Just sort of what comes out. So if the operation is equal to the addition symbol Let's start building that one out. So we've got a beautiful if statement there So if the variable operation, let's go get that variable if the variable operation is an operator We're comparing now. I want to compare the operation. It's equal to positive If you've been following along in this video series, this block should be looking pretty Familiar to you because you've done it before so if the variable operation is equal to the addition symbol then We want to check for some more conditions if the variable. Let's go get another statement if the variable Number of integers to move Is greater than zero? Okay, so we're not comparing this time where we need the greater than simple remember greater than symbol The the side that has the greater space opening towards it is the greater side Okay So if the number of integers to move is greater than zero related to 50 that's going to be a big bug Then we need to broadcast add positive Okay, let's get into our events and we know that that is an event there We need to broadcast not add negative, but we need to broadcast add a positive I'm going to be up the top right beneath it. Okay, then we need to get our back to say that we need to add a positive So let's go into our looks Let's say And positive and Add Okay, so what I want to do now is after we do a bit of code I just want to go ahead and test it We can't directly test this one because currently our operation is subtraction and here We're only got a condition set up for if our operation is positive for what we can do You just break out this basic code attend that we meet the conditions I just want to see if the animations and what the bat says works. So broadcast Add positive Cool. So you can see that we had some fire there for our play to balloon and our bat is now saying add positive So I am positive that that code is working as it should Let's go back to our plan planer here. So we've done this block here this one now We need to account for our third one. I'm just going to duplicate that if statement there and No longer are we comparing for greater than we need a less than Operator here. So let's go grab one of those That number of images to move is less than zero Means it's a negative and we're actually going to be adding a negative in that case. So add negative Okay, let's try keep her consistency sometimes I'm pretty inconsistent when it comes to this, okay so let's go ahead and Follow through what this block needs to say. So we're going the greater than less than pattern again. So let's just duplicate this whole block here and Change it for our Subtraction scenario. So if the operation is equal to the subtraction symbol if the operation is equal to the subtraction symbol Beautiful if the variable number of images to move is greater than zero Now remember if our number of images is greater than zero and this is probably a good opportunity To jump over here, which is the scenario we have at the moment. We've got our operation, which is Subtraction and we're going to be taking away Okay negatives. So remember negatives are sandbags and bags weighs down We're actually gonna be getting rid of sandbags and that means that lifts our balloon up and for that case We're going to be subtracting a Negative so That's when our number of images to move is greater than zero. So the condition that we need to say here is we're subtracting a negative So subtract Negative Pretty sure that if I press this we should see some sandbags drop from our balloon here There we go, okay, because we've just popped in the code to account for what our current deal has Happened here. Okay. We need to go ahead and complete the last condition For our co-block here So if the number of images to move is less than zero and we need to broadcast Subtract a positive. So that's this one here and let's go subtract Positive all right Let's drag our scratch window here. We're done with our planner for now I think it's good for us to go ahead and just put this into action now So we've got this where the bats waiting for us to input our solution into here. So we're currently on player two We need to take away Six negatives. Okay, so that's as we as we know that's going to increase our height by six We're currently on six. So that's gonna take us to 12 and that is correct there go those sandbags and Player two is only eight away from victory. Okay, let's steal some cards Okay, now we are going to be taking away the 10. So say move type We is the operation positive or addition or subtraction. Well, it's subtraction isn't it? Okay, is the integer Positive or negative? Well in this case, it's a positive integer. So if we take away a positive integer We're going to end up with a Negative result. So in this case our number of images to move is going to be less than zero. So we're subtracting a positive That's exactly what's going to happen here. We're subtracting a positive integer. So take away 10. So we're negative 3 That's going to take us to negative 13 And there's our deflation animation Happening let's do one more to see if we get a different result. So we're going to be taking away Another negative this time. So this is increasing our height because we're going to be Taking away more sandbags and add seven to our height here And that'll take us to 19. So we want away. So let's say put in 19. That's correct There you go all those sandbags. Okay So our game is functioning as it should be. We have managed to figure out the logic We needed to get our animations working our feedback working and also Calculating the number of images to move That's all for this video and that brings an end to our series on up down flying around Programming is beautiful in that there are so many different ways to do the same thing Did you implement same move type differently? Did you calculate the number of images to move in a different way than what I did? Let me know in the comments section below. Link me to your remix project. I'm super keen to see it 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 I'll be releasing more units in the future. But until then I'm off to go find a wave. Take it easy