 Done all the hard work, now it's time to make this game actually playable. In this tutorial, we're going to be adding a background to snazz it up. We're going to be creating some feedback for the user at the endgame to signal whether they're won or lost. And I'm also going to share with you some extension ideas to take this game even further. I'd love to see where you're taking it. So let's dive into it in just a sec. Hey what's up crew, it's The Surfing Scratcher here, teacher-surfer programmer and I help curious people just like you along on their learning journeys through video tutorials. Welcome to the final video in our Trigonometry game series. I hope you've been enjoying it. In this tutorial, we're going to put the finishing touches on our game so it actually becomes a game and I'm going to give you some ideas to extend this game even further. As always, go and find the starter project down below in the description so that you can work along with me on this project. Okay, let's get into it. First thing that I want to show you is this windscreen sprite that I've created. What this will do is it is just some feedback to tell the user that they've either lost the game or they have won the game. You can just create your own custom one of this by having two costumes. That's all you'll need to do or use the starter project if you want to use this screen. And I'm going to head over to the stage code area because that's where I like to put all my sort of overall game logic about a when the green flag is clicked. Then we're going to get a forever loop. Then we're going to create the logic for when our game is over. We know that our game is over when our ship lives or turret lives is equal to zero. So let's go grab those variables ship lives is equal to zero, duplicate this and change ship lives to turret lives. So a game is over when either of these are true. So I'm going to put that in an all block and then whack that in the if condition and put this if block inside that forever loop. Next, we want to stop this script. And before we stop this script, we're going to broadcast a new event. And that event that we're going to broadcast is going to be called game over. Now I'm doing it this way because this is a really quick and efficient way to do it, but it's not necessarily going to be bug free. But this whole series has been about trigonometry and I just want to tie up the loose ends. Now just before we leave the stage bright to work on our windscreen sprite, let's jump into the backdrops. Let's choose a new backdrop. I think there's a space one. There's one that's got stars. Yeah, that's going to be really nice for our background. Beautiful. OK, let's jump across to our windscreen sprite. Drag out a when the green flag is clicked. And I'm just going to show our windscreen so you can see it on the screen. And the first thing we want to do, we want to set the ghosting effect. We're going to set the ghosting effect to 100. If I click this, you'll see that it disappears off the screen. If I press the stop sign, it'll come back. So as soon as we click the green flag, we're going to make this windscreen transparent. And we're also going to hide it. OK, let's drag out an event hat block when I receive game over. So this sprite is going to receive that event that the stage was firing off. The next thing we want to do is we want to determine whether or not ship lives is equal to zero or turret lives is equal to zero. So let's put both of those in equal operator blocks. And then we can put both of these inside their own if blocks, just like this. So we'll receive game over once and we'll check to see if ship lives is equal to zero. We'll also check to see if turret lives is equal to zero. This doesn't account for the very slight possibility that both of them will be zero at the same time. The internet may break down if that happens, but it's a risk we're willing to take for this game. And we're going to jump into the looks category and we're going to switch the costumes. So when the ship lives is equal to zero, well, that's when the player loses. We're just going to duplicate this. And when turret lives is equal to zero, well, that's when the player wins. The cool thing is that we can pair these with some built-in sounds. Head over to the sounds tab. You'll see here, I've already got the lose and win sounds here. If you want to know where they are, just go into the sound library and press choose a sound and go and find them by pressing win. There we go. I'm going to play the sound until done. So when the player wins, I'm going to play win until it's done. Duplicate that or play the lose sound until we're done. Now let's just test this out. I'm going to right click and make this a slider. Click the green flag. And then we're going to slide the turret life to zero. And there you go. We have one, but we can't see our screen yet. So I'm just going to press the stop sign. So we need to show our screen and also fade it in. We're not going to do that in this game over hat block. That's because when we play a sound until done, it blocks the thread. So I'm going to do something a little bit sneaky and a little bit lazy. I'm just going to start a new sequence of instructions when we hit game over. I'm just going to wait, say, half a second first, just to give our sprite here a chance to switch to the right costume. And then we're going to show this sprite. Then we're going to repeat for, let's say, 50 times. We're going to change the ghosting effect by negative two. Because if we change it for negative two over 50 times, or two times 50 is just 100. Negative two times 50 is negative 100. And recall up the top here, we set it to 100. So essentially, we're just transitioning it back to zero. OK, let's test that out. Click the green flag, drag it back down. Boom, that's looking pretty nice. But our game is still playing in the background. Our turret missiles are always going to be firing at the rocket in the background. So let's go over to our turret missile. And when we receive game over, let's just stop other scripts in this sprite. So that's going to bring a halt to our broadcast shoot turret missile. Now that we have this piece of code, we can just drag it and put it on top of the rocket ship. So we'll stop all the rocket ship movements. We can do the same thing with the asteroid. And we can do it with the turret as well. But that one is not so much of an issue. OK, we've been testing out with our turret live. So let's go check it out with our ship live. So I'm clicking the green flag. I've got the trigger option open. And there we go. There is our blue screen. One of the final things we can do with our game is add in a background sound. So let's head back into the backdrops. Just going to duplicate this block of instructions because we want the forever loot and the green fly click. We'll get rid of that if block statement. And then what we're going to do is we're just going to play a looping sound until done. You don't want to use one of the built-in scratch sounds. Go find one out on the internet and drag it in. But I'm just going to use a built-in sound. The built-in sound that I'm going to use is going to be a game loop. So if we click the loops filter, I'm going to scroll right down to the bottom and go to video game. And this is the one that I want. I want it to be kind of a little bit intense. So after 6.82 seconds, it's going to replay itself. So let's go back into the code. We want to play that sound until we're done. So video game sound. Okay, I'm just going to reduce these variables. In fact, you could even hide them, but I'm just going to leave them there so you can see them. And then we have it. We've got our background music happening in the background as well. And I'm just going to press the stop sign. I notice our missiles don't make a sound when they fire. So you could go ahead and add a sound in for that too, if you wanted to. And that's it. These are the basic building blocks of a space shooter game. If you made it this far, you are joining an elite club because there wouldn't be many people who have completed this whole series the whole way through. I'd say close to kind of like 2 to 5% of people who actually started this would follow through the end. So congratulations if you're one of them. And you've taken huge steps in building your understanding of trigonometry. But of course it's an ongoing journey and you need to reinforce it. So where do we go now? Well, I'm going to give you around six ideas on how you can extend this game. And I'm also going to be making a couple of other trigonometry videos as well to explore some functions that we didn't explore in this series. Namely, the arc cause and the arc sign inverse trig functions. Okay, let's get to those ideas. So one thing that you could do is currently our turret fires a missile in a straight line. You could create a heat seeking missile. So using the logic that fires this missile in a straight line, you can just update its direction based on the new triangle that you would draw every single frame. If you want a refresher of that, there's a card in the top right hand corner to remind you how we got that missile firing. Now we've got a heat seeking missile. That's an advantage to our turret. So what could we do to our rocket ship to evade it? Well, I suggest we could modify the acceleration. We could hit like a booster button that will get out of the way of that missile. And that's why we just want to change the speed of the ship over a period of time. As mentioned in the last tutorial, you could create multiple asteroids. And you could have the need of the user to destroy these asteroids before they get to the turret. You could even go into the costumes and have some different damage levels of the asteroid. So here it is in its complete intact state. You could have a state where you would erase some of that asteroid until it's all gone. You do that over multiple costumes. You could create multiple levels for this game. And the way I do that is I'd have different turrets. So if we go into the turret costume, we could duplicate this costume and change different colors. And then what I do is I go into the turret missile and I change the pace at which we fire those missiles. So at the moment, it defaults to three seconds and I'd shorten that as the levels get harder. I might also increase the speed of those missiles, which looks like we're already doing here anyway. But instead of using the timer, I might use the costume number of the turret. Now, if the game's getting harder, we might want to wait for our rocket ship to increase its health. So you could have some health packs, scatter them around space over different periods of time. There you have it. There are some multiple ideas that you can use in your game. Do you have any more ideas? Share them with us in the comment section down below. And hey, if you've made this game, I'm gonna set up a studio where you can add your version so we can all check it out together. Thanks for playing along Space Get It. I hope you enjoyed it. Yeah, we made it. That's it. I hope you enjoyed this Scratch Trigonometry series. Congratulations on marching through it. I just want to give one last final shout out to the original tutorial that inspired me to make this monster on raywanderlake.com. There's a link in the description for it. If you're curious about making iOS applications using Xcode and Objective-C, then go check it out. Hey, you've already done it once in Scratch, but it's pretty advanced. Now I'm gonna take a few weeks off to generate some new content for you guys. But hit me up in the comment section down below to let me know what you'd love to see on this channel. I've been feeling pretty sparkly by learning systems and methods that I want to share with you, so I reckon that's where we'll head first. Remember to check out the Patreon link on your screen right now to continue to support this channel. But until next time, I'm off to go find a wave. I'll catch you in the next one.