1 00:00:00,450 --> 00:00:01,510 Hi, welcome back. 2 00:00:02,070 --> 00:00:12,360 And this video, we will apply the collisions between the bird and the pipes, but the question is how 3 00:00:12,840 --> 00:00:14,040 we can do that. 4 00:00:15,300 --> 00:00:25,680 We can do that using the rectangles around these pipes and this bird and check the collisions between 5 00:00:25,680 --> 00:00:27,600 these rectangles using. 6 00:00:27,960 --> 00:00:37,380 We will create a new variable called game underscore on our game on equal a volume value through. 7 00:00:37,860 --> 00:00:42,710 Then we will create a new function called collisions. 8 00:00:43,140 --> 00:00:49,890 So the F collisions between two parentheses by its then column. 9 00:00:50,340 --> 00:00:56,370 Then inside this function we will pass as the following. 10 00:00:56,590 --> 00:01:10,320 So instead of best, we will add a loop four by and by column F bell dot collide between two parentheses 11 00:01:10,500 --> 00:01:16,300 by column and inside the statement that will return false. 12 00:01:16,560 --> 00:01:23,490 So the game will of not on all the game will end. 13 00:01:23,940 --> 00:01:35,940 And also if that underscore rectangle dot top less than or equal twenty five or better underscore rec 14 00:01:36,570 --> 00:01:50,100 bottom more than four equals four hundred thirty five which is the top of the gameplay and the bottom 15 00:01:50,340 --> 00:01:52,810 which is the base of the game. 16 00:01:54,270 --> 00:02:04,050 So if the word collide with the base for the top of the gameplay, the game will over and the player 17 00:02:04,170 --> 00:02:05,040 will lose. 18 00:02:05,820 --> 00:02:11,250 So this second statement will also return false. 19 00:02:11,860 --> 00:02:19,160 OK, and if the two conditions not having the function return, true. 20 00:02:19,440 --> 00:02:28,200 So the game is on and the player will continue to play the game and we need to adjust these lines of 21 00:02:28,200 --> 00:02:34,260 code and cut and paste that inside. 22 00:02:34,290 --> 00:02:44,520 And if statement is the following and also by underscore, let's two to be equal five underscore move 23 00:02:45,090 --> 00:02:54,870 between two parentheses by underscore less to two and assign the variable game on to a new value to 24 00:02:54,870 --> 00:03:00,990 be equal collisions between two parentheses by choice underscore two. 25 00:03:01,170 --> 00:03:11,760 So this part of code will only function if the game is on and if the game is not on board, the game 26 00:03:11,760 --> 00:03:13,920 is over and the player lose. 27 00:03:14,370 --> 00:03:25,200 This part of code wasn't working and if we build our Brozak, we will find that we have an error due 28 00:03:25,200 --> 00:03:31,580 to wrong identification of the return two of the collision function. 29 00:03:32,730 --> 00:03:40,260 So we will fix that by adjusting the wrong identity and then build our project again. 30 00:03:40,680 --> 00:03:45,870 And our game will work fine without any error. 31 00:03:45,990 --> 00:03:50,160 And we will build our project again to check the collisions. 32 00:03:50,670 --> 00:03:53,340 And our collision is working fine. 33 00:03:53,640 --> 00:04:01,270 But we have a small problem that our game is still running without the fights and the bad. 34 00:04:01,290 --> 00:04:08,510 Please take ten seconds to think about the way we have to solve this problem properly. 35 00:04:26,340 --> 00:04:31,110 We can solve this problem by change the statement. 36 00:04:32,940 --> 00:04:37,770 L.F. not even the type that would equal by game dot. 37 00:04:38,710 --> 00:04:48,600 OK, that one and the ad and game underscore on double equal to column, so the statement and the nested 38 00:04:48,610 --> 00:04:55,960 F a statement inside that will not work until the two conditions are through. 39 00:04:57,310 --> 00:05:06,340 We will copy the same lines of code again with some changes, with some changes as the following that 40 00:05:06,340 --> 00:05:10,160 game on equal force in the state of true. 41 00:05:10,570 --> 00:05:18,880 And also, we will remove the word movement, two lines of code and add Vibe's underscore to the clear 42 00:05:18,880 --> 00:05:28,810 method to clear the pipes after the game is over and the ad game underscore on, well, equal through. 43 00:05:29,770 --> 00:05:38,670 So the game will start again, then adjust the movement again at zero value. 44 00:05:39,130 --> 00:05:47,550 Then we will build our Brozak the game to ensure that our project is working fine without any errors. 45 00:05:53,400 --> 00:06:00,240 So the game is running OK and restored correctly without any errors, as you see. 46 00:06:02,630 --> 00:06:07,850 But in case the bell collide with the game base, there is a problem. 47 00:06:07,890 --> 00:06:12,230 OK, we will solve this problem through the following solution. 48 00:06:12,350 --> 00:06:20,780 Bears underscore rectangle center equal between two parentheses twenty five comma two hundred fifty 49 00:06:20,780 --> 00:06:23,510 five and build our project again. 50 00:06:25,520 --> 00:06:32,660 And we see that half the words collide with the top or the bottom, which is the base of the game. 51 00:06:32,810 --> 00:06:36,080 The game will start by clicking pace. 52 00:06:36,320 --> 00:06:41,840 So if we run the game it will run until the world collide with the vibe. 53 00:06:42,200 --> 00:06:51,020 After each laughs by clicking this base and to start the game again, we will just click this game. 54 00:06:51,410 --> 00:06:54,560 At this point, we reach the end of this lecture. 55 00:06:54,590 --> 00:06:57,820 I hope you enjoyed this lecture and get all of that. 56 00:06:57,830 --> 00:07:00,660 Thanks for watching and thanks for being here. 57 00:07:01,070 --> 00:07:02,950 See you next, Viju.