1 00:00:00,000 --> 00:00:01,410 SPEAKER: All right, in Pong 11, we looked 2 00:00:01,410 --> 00:00:04,077 at adding sound effects to our games, so a little bit of polish. 3 00:00:04,077 --> 00:00:06,045 My favorite, I think, iteration of the track 4 00:00:06,045 --> 00:00:07,920 makes the game feel just a little bit better, 5 00:00:07,920 --> 00:00:11,910 hearing actually things happen when you're manipulating the game space. 6 00:00:11,910 --> 00:00:16,350 This update is quite a bit simpler, and simple just altogether. 7 00:00:16,350 --> 00:00:19,050 All we're doing is adding the ability to resize our application. 8 00:00:19,050 --> 00:00:21,050 So we can do things like this, where we actually 9 00:00:21,050 --> 00:00:23,190 see letter boxing because we've resized the window 10 00:00:23,190 --> 00:00:27,510 to be more of a square, even rectangular, sort of vertically aspect 11 00:00:27,510 --> 00:00:28,560 ratio. 12 00:00:28,560 --> 00:00:31,950 But notice that Pong, the window itself, is still 16 by 9. 13 00:00:31,950 --> 00:00:33,210 So it looks like it should. 14 00:00:33,210 --> 00:00:33,945 Thanks to push. 15 00:00:33,945 --> 00:00:35,850 Push actually takes care of this pretty well. 16 00:00:35,850 --> 00:00:37,725 So what we're essentially going to do is call 17 00:00:37,725 --> 00:00:41,350 the love.resize function shown here, which takes a width and a height, 18 00:00:41,350 --> 00:00:42,640 and pass those to Push. 19 00:00:42,640 --> 00:00:44,910 We're going to say push:resize width and height, 20 00:00:44,910 --> 00:00:47,860 and it'll end up taking care of all that fancy stuff for us, 21 00:00:47,860 --> 00:00:49,240 which is really nice. 22 00:00:49,240 --> 00:00:51,720 So I'm here in main.lua, right below love.load. 23 00:00:51,720 --> 00:00:54,660 I'm actually going to define a function, love.resize. 24 00:00:54,660 --> 00:00:57,468 We're going to just say it takes in W an H for width and height. 25 00:00:57,468 --> 00:00:59,010 Those can be named whatever you want. 26 00:00:59,010 --> 00:00:59,802 They get passed in. 27 00:00:59,802 --> 00:01:01,420 You can assign them whatever name. 28 00:01:01,420 --> 00:01:03,840 And we're just going to call push call and resize. 29 00:01:03,840 --> 00:01:09,600 If I can type, passing in those same width and height. 30 00:01:09,600 --> 00:01:11,850 And again, one other thing you need to do to 31 00:01:11,850 --> 00:01:14,940 is make sure that you set this resizable up here to true 32 00:01:14,940 --> 00:01:18,510 instead of [? string. ?] If I restart this, and I run the game, 33 00:01:18,510 --> 00:01:20,880 everything looks as it should. 34 00:01:20,880 --> 00:01:24,690 But if I go ahead and I redrag the window, 35 00:01:24,690 --> 00:01:27,870 you'll notice that it resizes appropriately. 36 00:01:27,870 --> 00:01:28,630 So it always fits. 37 00:01:28,630 --> 00:01:29,220 It looks a little weird. 38 00:01:29,220 --> 00:01:30,880 We're doing actual stretching process. 39 00:01:30,880 --> 00:01:33,810 But once you let go, it does indeed correctly 40 00:01:33,810 --> 00:01:37,858 resize Pong while maintaining the aspect ratio and adding some letter boxing. 41 00:01:37,858 --> 00:01:38,400 So that's it. 42 00:01:38,400 --> 00:01:40,560 That's all that we needed to do for that bit. 43 00:01:40,560 --> 00:01:44,250 And that's the end of Pong 12 and, therefore, the Pong track. 44 00:01:44,250 --> 00:01:46,420 The next iteration is actually on you. 45 00:01:46,420 --> 00:01:50,280 So this is Pong 13 with an asterisk, the AI Update. 46 00:01:50,280 --> 00:01:52,450 And this is actually the assignment for the track. 47 00:01:52,450 --> 00:01:54,900 So what we're going to expect for you to do 48 00:01:54,900 --> 00:01:59,460 is implement a basic AI to actually track the ball as Player 2 49 00:01:59,460 --> 00:02:02,430 and follow along and play with Player 1. 50 00:02:02,430 --> 00:02:04,922 Now, this can be as easy or difficult as you want it to be. 51 00:02:04,922 --> 00:02:07,380 You know, you could sufficiently make it impossible to win, 52 00:02:07,380 --> 00:02:10,454 but maybe making it possible to win, however 53 00:02:10,454 --> 00:02:13,680 it means you want to accomplish that, will make it a little bit more fun. 54 00:02:13,680 --> 00:02:15,555 But the only thing to really actually satisfy 55 00:02:15,555 --> 00:02:19,470 the criteria for this assignment is to just make it track the ball. 56 00:02:19,470 --> 00:02:22,190 Now, we want to make sure, too, that the tracking is smooth, 57 00:02:22,190 --> 00:02:25,882 that it's not instantaneous, because that would be unlike the actual game. 58 00:02:25,882 --> 00:02:28,590 So you might want to potentially think about looking at something 59 00:02:28,590 --> 00:02:30,660 like velocity to accomplish that. 60 00:02:30,660 --> 00:02:31,860 But this is CS50. 61 00:02:31,860 --> 00:02:34,920 This was the first half of the games track, the Pong version 62 00:02:34,920 --> 00:02:36,950 of the track, the very first half. 63 00:02:36,950 --> 00:02:40,380 In the next half, we're going to explore Super Mario Brothers, where we venture 64 00:02:40,380 --> 00:02:43,575 outside the world of shapes and very simple game mechanics, 65 00:02:43,575 --> 00:02:46,020 and actually look at a platformer where we control 66 00:02:46,020 --> 00:02:48,240 an avatar, specifically, an alien, and we even 67 00:02:48,240 --> 00:02:50,640 get our hands dirty with some procedural generation. 68 00:02:50,640 --> 00:02:55,430 So we'll see you soon for the Mario track of the games track. 69 00:02:55,430 --> 00:02:56,000