1 00:00:00,980 --> 00:00:02,520 Hi, welcome back. 2 00:00:02,540 --> 00:00:11,300 In this video, we will complete funkin and learn how to add paddleboards to the game display. 3 00:00:11,330 --> 00:00:13,180 So let's do that. 4 00:00:14,300 --> 00:00:21,350 So we will use by game module to create the puzzle sprites. 5 00:00:21,680 --> 00:00:32,090 So Spight is an object, have different probers like Waitz, height, color and extra. 6 00:00:33,260 --> 00:00:39,360 Also sprites have methods, jump, height, more forward and so on. 7 00:00:40,220 --> 00:00:48,680 So by creating the first Seasprite, we were to implement and use object oriented programming. 8 00:00:49,460 --> 00:01:00,830 So we will create a class for our paddles and get the two objects battle won and battle to from battle 9 00:01:01,040 --> 00:01:01,640 class. 10 00:01:01,670 --> 00:01:10,250 Thus, as multiplayer game contains two players, so every player will be able to control his battle. 11 00:01:10,550 --> 00:01:14,060 So battle one four, player one and battle two four. 12 00:01:14,060 --> 00:01:14,960 Player two. 13 00:01:15,050 --> 00:01:20,270 So we will create another file called Paddle By. 14 00:01:21,910 --> 00:01:31,930 Was small P and save this file, battled by as by filing in our folder bonke as the following. 15 00:01:33,740 --> 00:01:43,310 Then orbit the file and I'm bored by game, then we need to assign a variable called black, which contain 16 00:01:43,550 --> 00:01:48,960 a total of three integers, zero and zero and zero. 17 00:01:49,130 --> 00:01:59,910 We will try to convert this black variable from one goodbye module that we work on it in the first lecture. 18 00:02:00,210 --> 00:02:10,400 Then now we will create a class called Battle with the Capital as the following class battle between 19 00:02:10,400 --> 00:02:17,180 two parentheses pygame dot bright dot bright with as capital. 20 00:02:18,010 --> 00:02:21,950 Then close the parentheses and column. 21 00:02:21,960 --> 00:02:30,170 Then we will add the constructor method inside the class battle to initiate those characters as the 22 00:02:30,170 --> 00:02:40,220 following def double underscore and double underscore in parentheses and self comma color comma with 23 00:02:40,730 --> 00:02:42,230 comma height. 24 00:02:43,540 --> 00:02:44,770 Close parentheses. 25 00:02:45,890 --> 00:02:57,740 Then add column, then we will call the parent class constructor as the following Zober Dot Navot underscore 26 00:02:58,550 --> 00:03:01,220 and it doesn't underscore. 27 00:03:02,890 --> 00:03:06,610 Bob and parenthesis, close parenthesis now. 28 00:03:07,970 --> 00:03:19,390 We want to lessen the color of the battle and it's X and Y position and width and height and also set 29 00:03:19,400 --> 00:03:22,670 the background color and set it to be. 30 00:03:24,580 --> 00:03:25,570 Transparence. 31 00:03:26,990 --> 00:03:30,680 So self image equal by game dot surface. 32 00:03:32,320 --> 00:03:33,790 Between two entities. 33 00:03:36,680 --> 00:03:41,000 A list of width and height separated by comma. 34 00:03:43,130 --> 00:03:44,540 Self image. 35 00:03:49,430 --> 00:03:58,850 Between two parentheses, black and self-taught image said underscore Caraquet between two parentheses 36 00:03:59,120 --> 00:04:10,300 black, now we will draw battles using draw the direct method as the following pygame dot draw dot recht 37 00:04:10,340 --> 00:04:20,930 between two parentheses self image, comma, color, comma and bobin square brackets zero and zero and 38 00:04:20,960 --> 00:04:23,110 with comma height. 39 00:04:23,120 --> 00:04:26,200 Close the square brackets and close the parentheses. 40 00:04:26,210 --> 00:04:33,290 Then we will adjust the rectangle object that has the dimensions of image. 41 00:04:35,060 --> 00:04:39,320 So self destruct, equal self image. 42 00:04:40,940 --> 00:04:50,540 Don't get under correct between two parentheses, nothing, no parameters in this method, so the Salvador 43 00:04:50,540 --> 00:04:54,020 track will equal to the self image. 44 00:04:54,020 --> 00:04:55,670 Don't get the object or mass. 45 00:04:55,730 --> 00:05:01,940 Now we will build our Brozak to run our game and see if our code is run correctly. 46 00:05:01,970 --> 00:05:09,710 We find that we have an error that is the variable blank is not imported from BONKE, so we will assign 47 00:05:09,710 --> 00:05:10,400 it again. 48 00:05:11,920 --> 00:05:19,540 But in this battle, the fire has the following, so we will remove the import statement from BONKE 49 00:05:19,540 --> 00:05:26,530 and bought black, then black equal hateable of zero zero zero. 50 00:05:26,530 --> 00:05:27,620 Close the table. 51 00:05:27,880 --> 00:05:34,720 Now we will build our product again to run our game to see if it's run correctly or not. 52 00:05:34,720 --> 00:05:38,680 It will run correctly and without any problems. 53 00:05:38,680 --> 00:05:49,960 Then we will complete our code inside the battle by fire as a following by defining a function called 54 00:05:49,960 --> 00:05:50,530 models. 55 00:05:50,560 --> 00:05:56,350 Underscore moving underscore up which is responsible for moving. 56 00:05:56,350 --> 00:06:03,180 Our battle up will take two parameters self and number of pixels. 57 00:06:03,220 --> 00:06:12,780 So D.F. models underscore moving underscore up between two parentheses self and number of pixels on 58 00:06:12,790 --> 00:06:13,270 a number. 59 00:06:14,330 --> 00:06:24,260 And also underscore of underscore pixels, close parentheses column, then inside this function, we 60 00:06:24,260 --> 00:06:35,660 will assign self-taught rect dot y minus equal number underscore of underscore pixels and the check 61 00:06:35,660 --> 00:06:41,050 if we are not going too far of the game display. 62 00:06:41,510 --> 00:06:51,400 And to do that, we will use every statement as the following f self-taught rect dot y less than zero. 63 00:06:53,340 --> 00:07:03,780 Column, so self-doubt wrecked dot y equals zero, and we will define another function called battles 64 00:07:04,050 --> 00:07:11,330 underscore, moving, underscore down to control and move our battles down by the plate. 65 00:07:11,640 --> 00:07:24,050 So we will copy the first function as a following and paste it at the same ID again and change it to 66 00:07:24,630 --> 00:07:29,030 battles move down instead of up. 67 00:07:29,040 --> 00:07:41,190 So we have now to function or we defining two functions that able to move our battles up and down and 68 00:07:41,190 --> 00:07:43,250 control it by the players. 69 00:07:43,410 --> 00:07:50,220 But in case battles underscore moving town function, we will change that and f statement. 70 00:07:50,220 --> 00:07:58,710 If self doubt react that way, more than 600 column self dot dot y equals six hundred bexell. 71 00:07:59,070 --> 00:08:02,670 Now we've finished shooting but also by fire. 72 00:08:02,700 --> 00:08:10,380 So we will build it to see if we have any errors in this file at the following. 73 00:08:10,410 --> 00:08:17,210 But firstly we will on board battle in the main point by fire as the following from battle and board 74 00:08:17,220 --> 00:08:19,260 battle with B capital. 75 00:08:19,830 --> 00:08:28,230 Then we will declare Battle one and battle two to be assigned to the object of battle class as the following. 76 00:08:28,230 --> 00:08:38,250 So battle one equal battle between two parenthesis white comma, then comma and then close parentheses. 77 00:08:38,400 --> 00:08:39,510 Then we will. 78 00:08:40,020 --> 00:08:45,150 And the same for battle two will be assigned as object of battle class. 79 00:08:45,150 --> 00:08:54,030 So will equal battle between two entities white and the comma and then and comma and one hundred close 80 00:08:54,030 --> 00:08:54,630 parentheses. 81 00:08:54,720 --> 00:08:59,880 Then we will add the two coordinates for battle one and battle two. 82 00:08:59,880 --> 00:09:10,590 So battle one dot red dot X equals twenty five and one dot dot Y equals two hundred and fifty. 83 00:09:11,430 --> 00:09:20,880 Also for battle to dot dot x coordinate equals seven hundred seventy five and battle to attract dot 84 00:09:20,880 --> 00:09:24,330 y coordinate equal two hundred and fifty. 85 00:09:24,360 --> 00:09:32,490 Now we will create a list that will contain all Sprite we want to use in one game sprite underscore 86 00:09:32,490 --> 00:09:38,910 list equal by game dot dot group and and open and close to empty. 87 00:09:39,480 --> 00:09:48,990 Then we will add the two bottles to the sprite less so the sprites underscore less dot add between two 88 00:09:48,990 --> 00:09:58,170 parentheses by the one and try underscore last dot add between two parentheses battle to and add the 89 00:09:58,170 --> 00:10:07,860 same indentation of the for loop we will add kaze variable equal by game dot k dot get underscore press 90 00:10:07,860 --> 00:10:21,840 method and we will add four F statements to control the borders up and down using W and S and up and 91 00:10:21,840 --> 00:10:26,550 down in case at the keyboard by the player. 92 00:10:28,320 --> 00:10:34,980 So F K is between two square brackets by not K capital. 93 00:10:35,760 --> 00:10:37,980 Underscore w k. 94 00:10:39,100 --> 00:10:44,470 Collum battle won that battles moving up. 95 00:10:46,630 --> 00:10:56,830 Measured by seven pixels and we will copy the F statement that we created and bested three times again 96 00:10:56,920 --> 00:11:06,730 and change these additional three F statements to control the moving up and moving down of the two battles. 97 00:11:07,030 --> 00:11:16,690 So for the second statement will be F K is between two square brackets dot k underscore s. 98 00:11:17,880 --> 00:11:19,110 But the one that. 99 00:11:20,520 --> 00:11:27,360 Battles move, underscore, moving, underscore down between two Prentice's seven. 100 00:11:29,790 --> 00:11:38,900 And for the third one, if case between two square brackets by game dot k underscore up. 101 00:11:39,800 --> 00:11:46,460 In other case, letters so vital to the battles moving up. 102 00:11:47,520 --> 00:11:52,530 Between two parentheses seven and for the first one. 103 00:11:53,680 --> 00:11:59,050 If statement if case between two square brackets. 104 00:12:01,140 --> 00:12:13,980 By game dot k underscore down and other case characters or letters column battle to dot battles moving 105 00:12:13,980 --> 00:12:16,950 down between two parentheses seven. 106 00:12:17,220 --> 00:12:24,130 Now we will build our logic to run our game and see if it run correctly or not. 107 00:12:24,150 --> 00:12:25,610 It runs with error. 108 00:12:25,650 --> 00:12:33,160 This error due to a battle that by we forget to add the two parentheses of get wrecked method. 109 00:12:33,370 --> 00:12:41,730 Now we will run the game again by building our logic and our game run perfectly and our battles are 110 00:12:41,730 --> 00:12:44,750 moving correctly without no errors. 111 00:12:45,060 --> 00:12:48,250 And at this moment we reach the end of this lecture. 112 00:12:48,460 --> 00:12:50,960 Hope you enjoyed this lecture and get all of that. 113 00:12:51,540 --> 00:12:54,150 Thanks for being here and thanks for watching. 114 00:12:54,180 --> 00:12:56,610 See you next lecture.