 Okay, welcome to Simple Pong in Python 3, 4 Beginners. This is part 9. Again, this is one year and a half after the original tutorial was created. Again, today I passed 25,000 subscribers on my YouTube channel and here's what I'm doing with my time and excited energy. So in the last video we added an AI for the game, so the paddle B will play against the player. So what I'm going to do is I'm going to add a second ball to the game. Now I'm going to do it very basic style so that beginners can really understand it and just kind of see how things work. Now I always say this and I'm semi-serious about it, but semi-not-serious about it. So I like to say that I'm kind of a lazy person. So I'm just going to go ahead and copy this ball information and I'm going to go ahead and just call it ball 2, ball 2, ball 2, ball 2, ball 2, ball 2, and I don't want them to be on top of each other. So I'm going to go ahead and let ball 2 go to the left instead, doesn't matter, just pick something different. So I'm going to go ahead and run it and we'll see what's going on. And then from there we can kind of just debug it and work on the program and see what we need to do. Okay, so you can see we do have a second ball. The AI is still doing the AI thing, but this ball isn't moving, so let's go ahead and get that working. So again, if you understand how the basic program works, adding a second ball is very, very simple. So you see here it says move the ball, so I'm just going to go ahead and copy that and the astute amongst you will realize I'm just going to say ball 2. Now again, I'm going to go ahead and run it again. Now I know it's not going to do everything because I know there's, I haven't worked on the collisions and done a couple of other things, but this is the process. I'm just going to add it. Okay, let's see if it's moving. Beginners have this tendency to try to program the entire thing at once and then of course they get a bunch of errors and they can't figure it out. So if you do it step by step, you know that part, this first part is working. Now this is the second part. So I know exactly where to look if it's not working. I know where the errors are. Okay, that's interesting. Ball 2. Okay, so yeah, I missed that. Ball 2. I need to change them all to ball 2. It's really hard to talk and code at the same time. It's all I'm saying on the subject. Okay, let's go ahead and run that again. And there is ball 2. Now ball 2 just kind of bounced right off the screen because we didn't do any of the other code for that. So I'm going to go ahead and copy, basically just to copy all this code. I'm going to copy the border checking code, which is clearly not what we want to do, but I'm going to just go ahead and do that here, okay? And then I'm going to show you how we really want to do this, okay? So again, I am just fixing one thing at a time. So in this whole section, I got to change everywhere it says ball 2, ball 2. I could do a search and replace, but let's just go ahead and do this this way. This is my punishment for writing my code in a very poor fashion. And if you write your code like that, you should be punished as well because this is not the way you want to do things. Okay, so hopefully now the border collisions are working. I'm going to go ahead and run it again. Okay, let's see if it bounces down here. Okay, very good. So it did slow down, we see that a little bit in this game. Okay, so it's coming back and once it goes off the screen, it is going back to the center. Okay, so now we have to deal with the paddle and ball collisions. So I'm going to go ahead and copy that and get the same thing, ball 2, ball 2, ball 2. Okay, go over here to ball 2, ball 2, there's lots of these things here, ball 2, ball 2. And again, this is, you know, for a beginner who doesn't know any better, it's okay. We're not going to lose any sleep over it, okay? But again, once you get past the beginner stage, you want to stop doing things like that. In the next video, I'll show you how to get around this. At least that's the plan. So I'm going to hit run and run without debugging here on Visual Studio Code. And hopefully, the collision is working and so let's get out of here and see. Okay, so now it is working. But now we have a different problem. If you notice now, this paddle will only follow that ball. Okay, so again, when you add stuff to a program, you start to see, oh, I forgot this. I forgot that. The testing process is so important, okay? But again, I'm doing everything step by step. So for the AI player, what I'm going to do, and again, this code will work, but it's not, elegance is not efficient. It's not the best way to do things. Watch what I do here. I'm just going to say, so if ball.xcore is greater than ball2.xcore for the parentheses. So if ball1's x-coordinate is greater than the ball2 x-coordinate, that means that ball1 is further to the right. We want the paddle to follow it. So I'm going to go ahead and just copy that. And at this point, at this point, actually, what I could do is I could just put else. Because there's really only two possibilities. It's either greater than or it isn't. And if they're equal, it's not going to matter. So then in this case, I would put ball2, ball2, ball2, and ball2. So again, we're checking first to see which ball is closer. If it's ball1, then we do this code. Otherwise, it's going to be ball2, and then we do this code. So let's go ahead and watch it. Actually, let me do something to make it a little bit easier just to understand what's going on. I'm going to change ball2's color to, let's change it to blue, for example. That way, we know ball2 is blue. So let's watch this and see what happens to our... So we're following the white ball, we're following the white ball. Oh, did you see how it jumped up there? Whoa, that was fast. I don't know if that was fair. But okay, and then now you see how it jumped up there. There's probably something I should do to fix that, but I got to give that some thought. Again, as you're adding features, you will see that how, okay, this change here affects this thing over here that we thought was working just fine. And I do know how to fix it, and maybe we'll add that later as well. But I kind of thought that was kind of cool how it just kind of zoomed up there. But I do want to get to the next lesson.