Hi everybody. going to do a video hopefully as short as possible to walk you through how we can take a simple game and make it into something that will meet the requirements of the crate task. Some of the things I may add are maybe not that interesting to us, but they will allow us to. Maybe take a game that we want to build and care about and then also get full points on the create task. So this is a basic catch game, let me show you briefly again how it works. Right, then my score goes up, that's nice. We're going to have to make a few basic changes to even the rules of the game, but not too much. So just to show you we have a sprite the catcher ball that has our two sort of if statements that check and see if the event of a right arrow or left arrow being pressed move left, right. We're actually not going to mess with that at all. We actually are going to mess with everything in the apple sprite. Now you may be thinking as we go along, some of this seems like it should maybe not belong to the apple sprite and whatnot. But it's going to be easier for you to get to full points if you keep all of the complexity under one particular sprite. All right, so my basic process is that I'm going to take what right now is just one thing the game just plays and score is kept. And I'm going to change this into basically a three part Iterative or sequential process. I'm going to have an introduction that I'll add before we play the game. There'll be the part where the game is played. And then I'm actually going to change it so that it stops after you catch five apples so that I can have a third part that'll be the conclusion. And that's going to really help me make sure that I've got, I get my four points for having an algorithm that has at least two other algorithms inside it. In fact, I'd probably argue that mine is going to have three other algorithms in it. But by having that extra complexity, I think I can make sure that the greater will give me the four points. So, one of the easiest ways to make it really clear that something is an algorithm, is to encapsulate that entire algorithm in a method, or a block. That's not necessarily required, you can write it all out as one big piece of code and then circle the different parts of the algorithm. But, let me tell you, you make it really easy for the grader, if you have these set up as actual blocks or methods. So I'm going to make one called introduction, okay, and we'll talk about what that's going to be later. I'll just get them all set up first, and we're going to be like, okay, play the game. Okay, and then I'm going to have a congratulations at the end. All right. Now I can figure out what goes in there and what not. Let's do the introduction first, so, I mean, I just need to have something in there that is more than one or two instructions, so it can do whatever. I'm just going to say. Maybe I'll have it say. I think I'm going to ask the user a question. I'll say, what's your name? And then the person will type something in. And I'll say, That name back, so I gotta go pick up my answer here. I'll say the name. And then I mean, I could do some fancy join or something. But actually, I'll just go back and say thanks for playing my game. All right, now that doesn't have any math or logic in it. So I'm not going to be able to use that as my algorithm that has math or logic. But it's a clear introduction. If I wanted to be like I want it to be like even cooler. How about if we do play the drum? All right, so there's my introduction. Now what I need to do, is I need to modify this code when the thing is clicked to do my introduction first. All right, so dun dun dun, drag that off of there. My introduction is going to go first, now this will go back on there. Actually, it's not going to go back on there, but whatever. So let's go ahead and play and see what we've got. What's your name? Beth. Hey, Beth. Thanks for playing my game. And I don't have my sound on, so you can't hear that. All right. And at that point, and only after that, interestingly do you know that the apple starts falling? Now, this code was actually also running at the same time, but we don't even have to worry about that. This is one of the challenges with the requirements in the algorithm, and the sort of parallel nature of Snap. Where you can have lots of different scripts going on at the same time, and I could circle each of them as different algorithms. But again, one of the key things is that I have to have an algorithm, that calls two other algorithms within it. And one of them has to be sort of independent. And already this is an independent thing, the introduction could be independent. But what I want to do is I want to take out most of this stuff and put it in the play game part. So that should all come after that so we'll do that. Move this guy around down here. And so now we can say play game. All right, let's see how that goes. What's your name, Beth. Hey Beth, thanks for playing my game. Okay, and I can go on, cool. Captured, captured, captured. That's neat, got it, got it. Yeah, but I wanted to have it end, right? After I capture it some number of times. So, I'm going to change my play game now so that it doesn't loop forever, but it actually loops until the score is five. So let's get rid of that. And this is snap, so it has this lovely repeat until. And I want to say until the score is greater than 5. So, where's my [INAUDIBLE]? It's not sensing, where is it? Operators, duh. All right, until something is greater than five and that something is in my data because we had already made this data variable for score. Cool, so starting the game, it's going to go to a random position. Set the y to 180 and then repeat until the score is greater than 5. Okay, cool. By the way, this is sort of sitting there in some random location. I might want to fix that eventually, but we'll see. Beth. OK. Thanks for playing my game. That's nice. Can we catch you there? One, two, three, four. Has to be greater than five, And it stops. Pretty good, nice. So I've got something that does two things. What about the congratulations part? All right, so we can, again we don't have to do much but I'm going to do maybe more than just a few little things because I do want to make sure that I've got math and logic in there. This one has math and logic in it both, I think it's got logic here, it's got go to random position. Go to random position I think counts as math. But we can do other things just to spruce it up to make sure. Let's see, I'll just show, be like, maybe I can even just do, I can do a repeat ten times, no, I don't want to do it ten times, how about four times. And I will say, how about the following, I'll say, Congratulations, And then I'm going to do, Let's see, I don't know, maybe a sound? Maybe I want to play pop and, just to make it be a little more interesting I'm just going to maybe turn, I'll just have the flip around every time. Okay, let's try that. I want to fix this. I don't like the fact that the Apple ends up randomly someplace. So I'm going to just put at the very beginning here. I'm going to have a go-to. I want it to be like the beginning before the introduction go to zero, zero. So, maybe it'll go to the middle. There we go. Now, I can put my name. La la la, thanks for playing. That's nice. Catch, catch, catch, catch. Okay, next time, I'll be able to make it three. All right, it stops. Why did that happen? Can you see? Go to 0, 0, introduction, play the game, I never called the congratulations method. All right, all right, yep. And I can check it and do all that. And one of the things I notice already is that when I do congratulations again, I really want to have it be at zero, zero. So, in fact, I tell you what, I'm going to put another one of these in here. And you could argue I think that should be at the top of the congratulations method. And I think you could do that. I'm going to kind of put it there just to make this look like it's not just three algorithms in a row with nothing else in there. I think that is legal by the definitions of the rubric, but you know the rubric's really hard and my goal is, for even myself as a student or as for others, that we make sure that whatever we do gets that full credit. All right. Catch, catch, catch, catch, catch, catch. All right, congratulations, now it's flipping. Congratulations, congratulations. Congratulations, congratulations. All right, so why do I add this repeat and all this stuff? Why don't I just say congratulations? Well, if you're just saying congratulations, that's a single instruction, and just sticking that inside a method, that's not enough for this to be called an algorithm. Because this is like a little dance here or something, right? It's more complicated that my congratulation is like a scene. Then that I think is what means that it's really an algorithm. Same thing here. I have sort of multiple things that come together for the introduction, and so collectively, I would call that an introduction. Also, by the way, just the use of these terms that teachers are going to be familiar with, like from a movie. There's an introduction. There's the main part, and there's the final or finish. That's going to be using those names appropriately is going really help them be, of course, this actually is three algorithms together. Okay, so, let me go back to my rubric here. And we mentioned that one of the most challenging things is that you had to have an algorithm segment that uses mathematical or logical concepts. I would say I got that in spades here. I have this algorithm uses logical concepts. This one uses logical concepts so I'm good. The selected code which I'm going to say is this part here, implements at least two or more algorithms. I'm going to claim that this is my implemented code, and it actually implements three algorithms, so that's good. But if they were being picky, then I can say well those are my three algorithms, right, I don't actually have to say what they are. And at least one of those algorithms uses mathematical or logical concepts, so yep. Got one there, that's a mathematical or logical concept. And they work independently. Yeah, so I think we can stay here. The play game, one could be called from a number of other places and it works independently regardless of what the introduction or the congratulations is. So I think that's pretty good. And then yeah, by the way, we also have to then put a square around an abstraction. I can choose any one of these and say that's an abstraction. So quite simply, any time you make a method, that's an abstraction, okay? And that's why we just need to say that it has to be complex enough to merit being called an abstraction, you couldn't have just a couple of instructions in there. So we have some complexity in here. Repeat until, with an if statement inside definitely logic involved there.