 And welcome to Space Arena, the ultimate Python turtle graphics game tutorial part 18, where we make a splash screen. So a splash screen is a screen at the beginning of the game. It kind of explains a little bit about that game. So I'm going to go ahead and run this, show you what we have so far. So basically, you see how the game just pops up ready to go. And we want to avoid that. We want to actually have a little screen that gives the player some time to adjust and see what's going on. So you can see over here, we've already created our own custom fonts. And we're going to be using that to do the splash screen. Now, we haven't used any custom shapes yet, but we will get to that eventually. And we also already have the radar. So I'm going to go ahead and close that. And what I'm going to do is I'm going to scroll down to about here. So you can see we've created this pen. And I think I'm going to try and put this 100% sure where this is going to have to go. Now, I think about it. So I think it's got to go down here a little bit. OK, so I've got a character pen already. And it's red. So here's what I'm going to do. I'm going to go ahead and try putting the splash screen in here. So I'm going to say splash screen. Because I've already created the character pen. So I'm going to just build on that and use it. So I'm going to say character pen dot draw string pen. Excuse me. And say space arena. I'm going to draw it at 0, 160. And again, I've already calculated these locations. So that's why I know where they are. Otherwise, you just got to play around. So now we didn't see anything there. So because once it gets to the splash screen, the game just keeps going. So I'm going to do the following. I'm going to say delay equals input. And that should stop the program from running. So I'm going to try that. OK, so you can see here, this is my splash screen. We've got space arena up on the screen, which is pretty cool. Now we'll fix the rest of that later. But what I want to do is go ahead and create the rest of the splash screen. So I've got space arena in large characters. I'm going to also say character pen dot scale. Because I have a scale attribute. So I'm actually going to go ahead and copy character pen. Because I think I'm going to be using this a lot. But here we go. So then I'm going to go ahead and do character pen dot draw string. Again, it's pen. And I'll say buy Tokyo EdTech, because that's me. And I'll put that a little bit below what I just did. 0, 100. And I can keep testing it, making sure it's where I want it to be. And that looks pretty good. I'm pretty happy with that. OK, so let's keep going with that. Next up, I'll say pen dot color, white, and pen dot shape, triangle. Because what I want to do is I want to actually put the player on the screen. So pen dot go to, let's see, negative 150 comma 20. And pen dot stamp. So I want to put that on the screen. So it's going to look something like this. OK, so that's my player. Next up, I want to go ahead and do character pen again. And it's still at scale 1. So I don't need to change anything here. And I'm going to say draw, draw string, pen, player, and negative 150 comma negative 20, I think it is. And again, like I said, I'm copying this because I've already actually calculated all this out for you. OK, so you can see I'm going to have a player here. So we know what the player looks like. And we're going to know what all the different items in the game look like. And so how are we going to play that? And then next up, I want to go ahead and do, let's see here. Let's say pen dot shape, circle, and say pen dot go to 0 comma 20, pen dot stamp, and character pen dot draw string, pen, enemy. There's a lot going on here. 0 comma negative 20, oops, 0 comma negative 20. So that's for our power ups. So I got messed up here. The enemy, actually, the enemy should be a square. I'm sorry, not a circle. Enemies are squares, square. I'm going to do basically the same thing for the power ups. So pen dot shape, that should be a circle, apologies. And pen dot go to 50 comma 20, pen dot stamp. And get it back to characters, pen dot draw string. And it's going to be just pen, and it's just a power up. So you can basically see what I'm doing here. I'm just kind of building it up piece by piece. And that's actually at 150 comma negative 20, I believe. So let's go ahead and test that. And I strongly recommend testing often, just so you can see where everything's at. And again, the colors aren't quite the way we want them to be. But we'll just leave that as it is. Because eventually what we're going to do is we're going to change that to GIF images. And it's going to look really nice. OK, so that is that part of it. Now I want to do the commands. So actually, I'm going to go ahead and copy this, because I'm going to be writing a lot of text on the screen at this point. And so watch what I do. I'm just going to paste that and get rid of that text. And I'm going to just put 0, 0. So I can just copy this. Let's see here. Two lines to ignore the bell. OK, so I got a bunch of different lines here I want to show on the screen. So the first one is the up arrow. And I'm going to put that at negative 100, negative 60. The up arrow is for accelerate. And I'm going to put that at 100, negative 60. So yeah, once you find the location of one thing, it's everything's just a variation of that. So left arrow is at negative 100, negative 100. And the left arrow lets you rotate left. And that's at 100 and negative 100. And let's see what else we got here. We got the right arrow, which is rotate right. And I'm just going to go ahead and check the coordinates there. This is also negative 100, the right arrow, and negative 140. And rotate right is at 100. And I'm hoping this comes out. Pretty sure it should, negative 140. And what else we got here? We got space, which is fire, fire or something, fire the missiles. And space is at negative 100, negative 180. And the fire is at 100, and also negative 180. Finally, we've got, let's see here, we got press S to start. And that's going to go at 0, negative 240. And I think what I got to do here for this is actually to set the scale. Make sure it's set back to 1.0. I might not need to do that, but just in case. Let's go ahead and run it. Okay, so there is my splash screen. Now you notice how it came up right away. So I'm going to do a little trick here. And if you go all the way up, and you'll remember, we did this command, win dot tracer. And what that does is it turns off the screen updates. So I'm going to actually cut that out for now. And then what I'm going to do is I'm going to put that after all of this stuff. So watch what happens. Now this is where it gets kind of cool. And now it's going to draw the text on the screen, line by line, literally. And now we have the delay going. But we'll get rid of that in a second. So now we've got kind of a cool little splash screen. Now I could have made this into an image, but because I really wanted that drawing effect, I think it's really cool, I did it the way I did it. So the problem now that we're having is that the screen, how can I put it? The screen basically stops. So if I take out this delay, and if I run it, watch what happens. OK, watch, that's pretty cool. We still get this, because we moved win dot tracer. Again, don't worry about the red enemy and red power, but we're going to fix that in another video. You could change the colors if you wanted to. OK, so you see how it goes right into that. So what I want to do is I'm going to go ahead and create in my game class. Where is that at? I want to say game self.state equals splash. So when I start the game, I'm in the splash state. So I wanted to have the splash screen. So what I'm going to do is I've set the state of the game. Now I'm going to go all the way down to the main loop. And I've done this in one of my other tutorial videos, explains this and why this works. So basically, what we're going to do is in our main game loop, we're going to do this. We're going to do this, if game.state equals splash win dot update. L if game.state equals playing, that's fine. Then everything here needs to be indented. So I'm just going to scroll down while I'm selecting it. I could use the mouse for this, but I'm using my keyboard. All that stuff. And what's nice is in Genie, I'm sure a lot of text editors, I can just hit Tab, and it moves the whole thing over. But I actually add spaces, not tabs, which is nice. So now if I run this, I got my splash screen. Now it's going to sit there because we never actually coded the part press S to start. So I'm going to go ahead and close that. Now we already know how to do these things. So we already know how to do on key press, et cetera, et cetera. So what I'm going to do is I'm going to say win dot on key press. And I'm going to use S because that's the S key. And oops, I'm actually wrong. I'm going to say game dot, that's called start. Let's call it that. Let's do it so we can use that. And I'm going to use S. And then just to be safe, I'm going to go ahead and do a capital S, just in case I have the caps lock on, so people aren't confused. So I need to go up to my game class, wherever that's at. Should use this over here, game. I'm going to make a new method. OK, I'm going to say def. What did I forget? I forgot what I called it already. Start game, start. And then what I'm going to say is I'm going to say self dot state equals playing. I just got to make sure that was the right thing. Game dot start. OK, so that should do it. Let's try it. Here's our splash screen. Do we feel lucky? Now later when we add some sound, we'll have some background music playing here. It'll be a really cool nice effect. OK, so the game is waiting for me to press S to start. I'm going to press S. And great, I got an error. Start take zero positional args. OK, duh. Because it was in a class, I got to put self in here. So hopefully some of you caught that. It's actually been a while since I've been working on this. So let's sit through that again. And that didn't work. Save it. The old one's still running, that's why. Let's get rid of that. Now here's my new one, hopefully with the S key working. OK, I'm going to press S. And now there is my game. So it's still running. See, just real quick, I'm just going to go ahead and fix that. Oops, I pressed that a couple of times. I didn't care for that on my splash screen. I wanted to make sure that it actually has the different colors for the power up. And I'm going to say pen.color, I believe it was blue. Yeah, once we switch these to images, it's not going to matter. But I think it's going to look a little better. There we go. And maybe I should make the enemy orange. But some of them are orange, some of them are pink, some of them are red, I think. So I guess it doesn't really matter. But yeah, that's it. That's our splash screen. And S to run it. So let me just review that real quick. So what I did was I reused my character pen class and the drawstring method, et cetera, et cetera. And in here, I created the splash screen. So I drew the text at certain coordinates. So that's, again, I just calculated it. I kind of played around with it. Now, when I first did it, the text was overlapping. So I had to move stuff down. So it just takes some time. And I started out with a large pen, I think 3.0, large size. And then I switched it down to 1.0 for everything else. And then I basically just drew the triangle, drew the string, drew the square, drew the string. And actually, let me go ahead and make this orange pen.color. Just give the splash screen a little bit of extra color. And then we have a blue circle. And then just drew all the text. And because I moved Win Tracer to after this section, it shows it line by line the way it's drawn. If you don't like that, if you just want it to come up right away, boom. You can move Win Tracer back to where it was at the top. And then in the game class, I made a new method. I made a new attribute, state. So when the game starts, we want to do the splash screen. So I call that state splash. And then when we press the S key, small or capital, we change the state to playing. And then that's done with the keyboard bindings. Now, a program this long, I should separate it out into separate files. Each class would get its own file. But for now, we won't do that. And here it is. So we did Win.onKeyPressGameStart. Doesn't matter if it's a small S or a capital S. And then in the while true loop, we had to do an if-elef statement. So if the game state is splash, we just update and just keep repeating this over and over and over again until we change the game state to playing. So if you think this through, this will allow us also to create a game over screen, where we can say game over. Here's your score. Press whatever to restart. So maybe R to reboot or whatever like that. So that is Space Arena 18. Thanks to everybody for sticking around. I do appreciate it. So please subscribe for updates. And yeah, keep on coding. Have a good one.