1 00:00:00,920 --> 00:00:02,130 Hi, welcome back. 2 00:00:02,150 --> 00:00:07,170 And this video, we will start quoting Pong game blown from scratch. 3 00:00:07,190 --> 00:00:16,250 So let's begin, as we learned in the video before this video, that we will begin our game by bored 4 00:00:16,430 --> 00:00:19,780 by game Python Library at the following. 5 00:00:19,790 --> 00:00:22,600 So a new folder called Pong Game. 6 00:00:23,240 --> 00:00:28,550 We will create a new file called Pong, taught by the following. 7 00:00:29,400 --> 00:00:38,010 So after all the folders, we will create another folder called Bong, then inside this file, we will 8 00:00:38,010 --> 00:00:38,720 create. 9 00:00:39,800 --> 00:00:48,380 A new file called Bong Dot by the following, so rename this folder as bong folders. 10 00:00:49,420 --> 00:00:49,930 Then. 11 00:00:51,390 --> 00:00:54,510 Create new file called Bongo's By. 12 00:00:55,760 --> 00:00:57,320 Inside this bond. 13 00:00:58,970 --> 00:01:03,980 But firstly, we will open this folder inside sublime text. 14 00:01:05,210 --> 00:01:08,990 Then create the bomb by five. 15 00:01:10,300 --> 00:01:15,100 By clicking on file, drop down, then choose. 16 00:01:16,330 --> 00:01:25,300 You file, then rename it to Bond to buy or save it as long goodbye five. 17 00:01:26,310 --> 00:01:36,420 And ensure that our bell system is Python and our views and Syntex view is Python. 18 00:01:37,500 --> 00:01:39,330 Then import pygame. 19 00:01:40,410 --> 00:01:41,470 By the module. 20 00:01:42,440 --> 00:01:47,150 Then we will add optional import statement. 21 00:01:47,960 --> 00:01:57,510 To import all the pygame methods as fallen from Bigham import Asterix, then we will import system as 22 00:01:57,510 --> 00:01:59,750 the following import as. 23 00:02:00,680 --> 00:02:01,670 Why is. 24 00:02:04,570 --> 00:02:10,820 Then build our project to ensure that all modules work correctly. 25 00:02:11,260 --> 00:02:18,640 After that, the next step to initialize pygame module, add the following. 26 00:02:19,610 --> 00:02:28,580 Using any method by game to end it and build our Brusic, it will run correctly. 27 00:02:29,060 --> 00:02:38,180 OK, this will initialize all methods and objects inside of our game to be used in our game. 28 00:02:38,180 --> 00:02:47,390 If we need to do that, then we will declare and assign our game variables and the following. 29 00:02:49,920 --> 00:02:51,270 Like equal. 30 00:02:52,290 --> 00:03:00,060 Zero zero comma zero inside to parentheses. 31 00:03:00,870 --> 00:03:01,350 Then. 32 00:03:02,570 --> 00:03:09,710 Also for white equal to parentheses inside the two parentheses, two hundred fifty five. 33 00:03:11,200 --> 00:03:18,400 Coma, two hundred fifty five, coma, two hundred fifty five and size equal. 34 00:03:20,080 --> 00:03:23,170 Eight hundred and six handwrote. 35 00:03:23,930 --> 00:03:28,250 Inside to parents is separated by a common. 36 00:03:29,520 --> 00:03:35,370 This represents the rights and height of our game display. 37 00:03:37,980 --> 00:03:47,220 And we also will assign the game display on the screen and the following game underscore display equal 38 00:03:47,220 --> 00:03:54,500 by game display, dot set underscore mode between two entities size. 39 00:03:55,390 --> 00:04:03,560 Also, we will name our game as bond using set underscore caption method of pygame module. 40 00:04:03,580 --> 00:04:10,270 So by game display dot set underscore caption between two parentheses. 41 00:04:11,250 --> 00:04:14,580 And to think it could. 42 00:04:15,620 --> 00:04:16,280 Bong. 43 00:04:17,240 --> 00:04:26,960 And run our game by building our project to get a black screen has our eyes of eight hundred pixels 44 00:04:27,230 --> 00:04:30,910 and a height of six hundred pixels. 45 00:04:31,770 --> 00:04:41,550 We want to start our game loop, and to do that, we need to create a volume variable that can be used 46 00:04:41,550 --> 00:04:43,660 inside the game loop as the following. 47 00:04:43,890 --> 00:04:48,060 So game underscore on equal to. 48 00:04:48,990 --> 00:05:00,060 Now we can add Zouliou or the game loop while game on Collum, now we will use the game clock and time 49 00:05:00,060 --> 00:05:02,940 to control our game speed. 50 00:05:03,860 --> 00:05:07,490 So block equal pygame. 51 00:05:08,400 --> 00:05:19,290 The time that clock with Capital S. then to parentheses and inside the while loop, we will add for 52 00:05:19,290 --> 00:05:27,330 loop at the following for event and by game event dot get method column. 53 00:05:27,930 --> 00:05:34,890 And inside the for loop we will add if statement as the following, if even the type doesn't equal by 54 00:05:34,890 --> 00:05:45,150 game dot quick column game underscore on equal fault and in the same identity of the for loop, we will 55 00:05:45,330 --> 00:05:53,970 make our game display blank as the following game underscore that fell between two parentheses. 56 00:05:54,420 --> 00:05:59,460 Then we will draw the neck of the game using pygame. 57 00:05:59,940 --> 00:06:08,400 Draw that line method so pygame don't draw the line between two parentheses. 58 00:06:08,430 --> 00:06:15,720 My screen is game underscore display comma and also game display is our self. 59 00:06:15,720 --> 00:06:17,510 My color is why comma. 60 00:06:17,580 --> 00:06:24,690 And we need to add the two points of the beginning and the end of this line, which is four hundred 61 00:06:24,690 --> 00:06:33,840 and zero between two square bracket as I separated with a comma and another list for the point to for 62 00:06:33,870 --> 00:06:43,620 the end of this line, which is four hundred and six hundred inside a list separated by a comma and 63 00:06:43,650 --> 00:06:44,220 coma. 64 00:06:44,430 --> 00:06:53,840 And lastly, we will add the width of our line, which is five pixels and close the parentheses of pygame. 65 00:06:53,850 --> 00:06:55,710 Gaudreau The time is now. 66 00:06:55,710 --> 00:07:05,860 We need to update the game display using update method of pygame modules as the following by game dot 67 00:07:06,030 --> 00:07:16,620 display the update method, then adjust the game frames to sixty frames per second using clock the text 68 00:07:16,620 --> 00:07:21,300 method as the clock the text between two parentheses sexy. 69 00:07:21,300 --> 00:07:30,930 Then we can now stop the game loop so the game stop running also using game dot method. 70 00:07:30,930 --> 00:07:38,020 Now we can run our game by building our process to see if we called our game correctly or not. 71 00:07:38,040 --> 00:07:43,890 So let's run it by clicking on tools and build our project. 72 00:07:43,890 --> 00:07:46,080 We will get a black screen. 73 00:07:46,410 --> 00:07:48,210 Has I made the line? 74 00:07:48,930 --> 00:07:51,060 OK, that's perfect. 75 00:07:51,690 --> 00:07:53,940 Hope you enjoyed this lecture and get all of that. 76 00:07:54,090 --> 00:07:56,550 Thanks for being here and thanks for watching. 77 00:07:56,580 --> 00:07:58,650 See you next lecture's.