SPEAKER: All right, in Pong 11, we looked
at adding sound effects to our games, so a little bit of polish.
My favorite, I think, iteration of the track
makes the game feel just a little bit better,
hearing actually things happen when you're manipulating the game space.
This update is quite a bit simpler, and simple just altogether.
All we're doing is adding the ability to resize our application.
So we can do things like this, where we actually
see letter boxing because we've resized the window
to be more of a square, even rectangular, sort of vertically aspect
ratio.
But notice that Pong, the window itself, is still 16 by 9.
So it looks like it should.
Thanks to push.
Push actually takes care of this pretty well.
So what we're essentially going to do is call
the love.resize function shown here, which takes a width and a height,
and pass those to Push.
We're going to say push:resize width and height,
and it'll end up taking care of all that fancy stuff for us,
which is really nice.
So I'm here in main.lua, right below love.load.
I'm actually going to define a function, love.resize.
We're going to just say it takes in W an H for width and height.
Those can be named whatever you want.
They get passed in.
You can assign them whatever name.
And we're just going to call push call and resize.
If I can type, passing in those same width and height.
And again, one other thing you need to do to
is make sure that you set this resizable up here to true
instead of [? string. ?] If I restart this, and I run the game,
everything looks as it should.
But if I go ahead and I redrag the window,
you'll notice that it resizes appropriately.
So it always fits.
It looks a little weird.
We're doing actual stretching process.
But once you let go, it does indeed correctly
resize Pong while maintaining the aspect ratio and adding some letter boxing.
So that's it.
That's all that we needed to do for that bit.
And that's the end of Pong 12 and, therefore, the Pong track.
The next iteration is actually on you.
So this is Pong 13 with an asterisk, the AI Update.
And this is actually the assignment for the track.
So what we're going to expect for you to do
is implement a basic AI to actually track the ball as Player 2
and follow along and play with Player 1.
Now, this can be as easy or difficult as you want it to be.
You know, you could sufficiently make it impossible to win,
but maybe making it possible to win, however
it means you want to accomplish that, will make it a little bit more fun.
But the only thing to really actually satisfy
the criteria for this assignment is to just make it track the ball.
Now, we want to make sure, too, that the tracking is smooth,
that it's not instantaneous, because that would be unlike the actual game.
So you might want to potentially think about looking at something
like velocity to accomplish that.
But this is CS50.
This was the first half of the games track, the Pong version
of the track, the very first half.
In the next half, we're going to explore Super Mario Brothers, where we venture
outside the world of shapes and very simple game mechanics,
and actually look at a platformer where we control
an avatar, specifically, an alien, and we even
get our hands dirty with some procedural generation.
So we'll see you soon for the Mario track of the games track.