 Hello and welcome back to Game Day of Academy. I'm Professor Whittington. I'm the one who's in charge of this little academy It's all mine. Let me know you're here by dropping a comment down below It could be any type of comment You could tell me how nice I'm looking today or it could be an ask for help Or it could be one of the memes that I've heard so much about in the last video We set up the game over state so that when we're out of lives we can kind of reset the game It'll all it'll all happen But what we'll do in this one is find a better way of communicating that to the player So I'm going to add some game over text to our hood that will pop up when all the lives have gone So let's get stuck into that after I tell you about this video sponsor Today we've partnered up again with out-of-the-box plugins to provide the quality content you deserve This time they've come up with an incredible tool to help automate more I'm talking about the clean project and then jump plug-in designed to optimize the way you keep your project Organized and the best part is that you can get a demo for free by signing up for their newsletter with the link down in the description Now that we can make it so the player runs out of lives and there's a game over state What we're going to have to do next is communicate that to the player and we'll do that through our heads-up display So we'll go straight into our hood Into the designer and we're going to put a game over message in the middle of the screen when all the lives have gone So to get started with that I'm going to create a new text block and What I want to do is anchor that to the center of the screen And I'm going to set the position X and the position Y to zero But if you look it's still not quite in the center and the way that we're going to sort that out is this alignment So if we do zero point five and zero point five That then puts it 50% on both axes along the way of the alignment which ends up being centered That's what we want. So that's now going to stay in the center. So for the text We're going to want it to say game over and I'm going to put that all in caps because I want this to look kind of old-school So we'll do that I'm going to put a sad face in there and I want to size the The text block to the content to make sure the alignment stays where I want it So that's a good start. We've now got it saying game over but I don't think it's big enough so Let's get the the size of the text a little bit bigger and to do that We're going to drop down this font section underneath appearance and we here we can change the font If you've got other fonts installed you can change them What all I want to do here is change the size So I want to change the size to something like 60 nice and big make sure the player can't miss it What we need to do next is put a behavior on this to make it invisible most of the time and only become Visible when the player loses all their lives and for that we need to scroll down to behavior and You'll see there's a visibility section and we can bind some behavior to that So I'm going to click on bind and then go to create binding and then the return node is Interesting whether or not it's going to be visible hidden or whatever so we need to set that up But we're just going to leave this here for now Because before we can get the text to be shown or not shown we need something to trigger it So we're going to have to go back into the game mode Set up a game over variable and we're going to use that variable to then trigger whether or not the text shows So let's get the game mode open Here's my BO game mode Here's all the scripts I've got in here so far and the first thing I want to do is just create a new variable and It's going to be called game Over question mark is it game over and we'll save that and it's automatically coming as a boolean Which is what I want because this state is going to be either true or false And then what I'll do is compile this because I want the default state of this to be false And we can see that it currently is set to false So I'll leave it like that. We want this not to be the text the game over text We want it not to be on screen at the beginning of the game So anytime we start a new game. We want to make sure that this script is also set to false so here's our reset game script and The last thing I want to do now is after we've reset everything else. We're also going to set the game over to false So every time we start a new game. It's no longer game over Whenever it's game over we need to set the game over variable to true so what we're going to do is Get game over here and we're going to set it to true whenever game over happens and Then what we'll do is add a delay of five seconds So let's just set that to five Before it quits the game and we're going to change this quick game. I think in the next step to Just resetting the game so we don't have to exit the application But that should do it so game over should be the only thing that sets the game over to true Everything else should be setting it to false. So we'll compile that and that will mean that now From our heads up display we can use that game state to decide whether or not this should be visible or not So we already set this up previously so we can get to the game mode. So let's get the game mode and Then out of here. I want to get game over We need to know what that is and then that's going to become a condition on what to show So what we want to do is is game over equal to something? There we go So if game over is set to true then we want to return the visible and we're going to go Backwards a little bit on this one and out of here. We're going to create a select There it is and what this is going to do is it if this is set to true We are going to have this be visible So what we're going to do is plug the result of this into the index and That gives us basically is it true or false? So if it is false We want it to be hidden if it becomes true make it visible and that's all we're doing to set this particular bit of The heads up display up. So now we need to run out of lives and test if this is working So let's compile and save I'm going to play And now I'm going to lose some lives Okay, so I'm down to my last life. So now I've just released the ball when this ball comes back down My hope is that it will tell me it's game over which it is it'll wait five seconds, and then it will close the app Hey, and everything worked. So that brings us successfully to the end of another step. Well done for getting this far You're doing very well at this. You're making a game. Well done So in the next one what we're going to be doing according to my notes is setting up the reset game So what that will entail is just when we lose all our lives instead of quitting the app will be set It's a quick step, but it's one that we need to do. So I'll see you for that one I believe that quality education should be available to everybody and for that reason all of the classes at game dev Academy are completely free and we're supported by our very generous school governors over at patreon if you'd like to become a game Dev Academy governor and support our work as well as helping us to steer the channel in the right direction Then use the link in the description to be taken to the patreon page