1 00:00:05,600 --> 00:00:07,700 Hey everyone welcome to this video. 2 00:00:08,250 --> 00:00:13,520 So in the last audio we have done finding some turtles and in this video we will move a little further. 3 00:00:13,730 --> 00:00:18,800 But one more thing I need to tell you that when you do not have any idea that what you are going to 4 00:00:18,800 --> 00:00:24,200 need and your program while defining a main logic then go for the main logic first. 5 00:00:24,380 --> 00:00:29,750 What I mean here is like if you can creating a calculator unit you are going to require some mathematical 6 00:00:29,750 --> 00:00:32,950 operations like addition subtraction and all this. 7 00:00:33,050 --> 00:00:38,720 Then you will define functions first and then go to mean logic and just call the function that you require. 8 00:00:38,720 --> 00:00:44,120 So same in this program we know that would really put something that will make sure that the caterpillar 9 00:00:44,120 --> 00:00:50,390 will not go out of the window when it go down something that will define give more and then something 10 00:00:50,390 --> 00:00:51,290 that will show. 11 00:00:51,310 --> 00:00:57,080 Final score and this score that we have at that particular point and something that will place the leaves 12 00:00:57,470 --> 00:01:05,810 and a number of more so few function that we are sure about will define him then we will define a main 13 00:01:05,810 --> 00:01:14,830 logic and the additional functions we require will define after the so for functions that you are angry 14 00:01:14,830 --> 00:01:21,070 that we are going to need in this program is first one is we will define something that will make sure 15 00:01:21,520 --> 00:01:28,320 that is a caterpillar inside or outside of the window second function that we do something. 16 00:01:28,310 --> 00:01:36,340 Place the Leafs as they list are not get edited by this will require something that will place the leaves. 17 00:01:36,340 --> 00:01:42,580 After that when we require something that will make sure that the game is over or the game is still 18 00:01:42,580 --> 00:01:43,060 going on. 19 00:01:44,380 --> 00:01:50,840 And after that when we require something that will display our score. 20 00:01:51,160 --> 00:01:53,920 So these are full functions. 21 00:01:53,920 --> 00:01:57,180 I believe every one of you are angry that we are going to require. 22 00:01:57,880 --> 00:02:04,990 So let me define or try to define these functions and whether we are capable of defining these without 23 00:02:04,990 --> 00:02:11,710 the main logic or not so we will go for the similar kind of fun like the outside window and place live 24 00:02:11,710 --> 00:02:18,510 this time and in the next video game over and displaying the score so for the outside window what I 25 00:02:18,510 --> 00:02:24,060 will do I will define these four walls just like the one that we have defined in the video and we have 26 00:02:24,060 --> 00:02:25,410 created a moving total. 27 00:02:25,620 --> 00:02:33,050 If you remember in the total module so we'll just like that one we have left one then we have right 28 00:02:33,060 --> 00:02:43,650 well then they don't fun and in the last we had the bottom one and how we will define them just by simply 29 00:02:43,650 --> 00:02:49,430 calculating the complete land dividing by two or adding or subtracting some factor. 30 00:02:49,590 --> 00:02:58,380 So the left wall will be equal to just simple like that one the DOT window underscored with it because 31 00:02:58,380 --> 00:03:01,800 the sun is actually good and this is the left one. 32 00:03:02,340 --> 00:03:10,550 So minus and only the left part so divided by two because we are first calculating the complete one 33 00:03:11,690 --> 00:03:17,390 and for the right will we had this one in positive and we are not adding some factor this time because 34 00:03:17,390 --> 00:03:24,320 we require of a caterpillar to pets defaults and then we have to spend more tumbles no one is just the 35 00:03:24,350 --> 00:03:33,180 window underscored height parentheses and then divided by two and bottom will be same of the top just 36 00:03:33,180 --> 00:03:34,030 the negative. 37 00:03:35,170 --> 00:03:43,250 So here we have defined all defaults and now I have named the function outside window so actually what 38 00:03:43,250 --> 00:03:48,330 I'm going to do in this function is having not defined that whether my caterpillar is inside of the 39 00:03:48,330 --> 00:03:49,000 window. 40 00:03:49,730 --> 00:03:53,080 I will define the whether it is outside or not. 41 00:03:53,270 --> 00:04:01,340 So whenever it crosses any of these walls it will provide me an alert by providing a Boolean true and 42 00:04:01,340 --> 00:04:04,390 then I will work on that one that my game is over. 43 00:04:06,260 --> 00:04:14,180 So I will take a variable here that is outside and that will check the portion of Caterpillar and the 44 00:04:14,180 --> 00:04:21,080 caterpillar positions will be again like the total positions just X invite and we can clear them simply 45 00:04:21,080 --> 00:04:30,580 just the name not position Neil now we have the x coordinate y coordinate it would all go to the left 46 00:04:30,820 --> 00:04:31,990 and right. 47 00:04:32,590 --> 00:04:39,940 Then if my X is less than the left window or begins a left ball then it means that it is actually out 48 00:04:39,940 --> 00:04:46,870 of this one and if it is greater than right then it means that it is out in right direction. 49 00:04:47,280 --> 00:04:52,100 So we can just add here or X greater than rightful. 50 00:04:52,350 --> 00:04:56,000 So I'm not taking hit inside like greater the next six is. 51 00:04:56,040 --> 00:05:00,710 And so adding left 1 and less than the right one I'm actually taking. 52 00:05:01,020 --> 00:05:08,160 When you get out of D so not the end here or end these things. 53 00:05:08,430 --> 00:05:14,680 And the other two conditions are also added with or because if the caterpillars get out of any of decide 54 00:05:15,230 --> 00:05:16,140 one game will be over. 55 00:05:17,310 --> 00:05:27,300 So y greater than the doleful or i vi less than the note. 56 00:05:27,350 --> 00:05:28,220 So a modern one. 57 00:05:31,060 --> 00:05:41,320 So in that case I will get this one so well this one that might get abilities out now and in that case 58 00:05:41,320 --> 00:05:48,380 I was just redone this outside which is going to be true if any of these conditions satisfy. 59 00:05:48,880 --> 00:05:56,700 Now we have this one so we are done with defining outside window and now we will define placing a leaf. 60 00:05:56,730 --> 00:05:59,830 So that is something very easy because we have no leaf. 61 00:05:59,850 --> 00:06:04,830 We have created a figure so positioning is it's very simple. 62 00:06:04,830 --> 00:06:07,380 Just first of all we will hide the title. 63 00:06:07,720 --> 00:06:10,330 So leave don't hide title. 64 00:06:10,560 --> 00:06:12,570 And that is actually already hidden. 65 00:06:12,690 --> 00:06:19,140 What I mean here is this will first hide the actual leaf that is eaten by the caterpillar right now 66 00:06:19,620 --> 00:06:22,340 so that it will it can place a new one. 67 00:06:22,350 --> 00:06:26,280 So first this one required to hide that one then a new one. 68 00:06:26,430 --> 00:06:28,190 And how do we find new one. 69 00:06:28,210 --> 00:06:32,590 So new leaf can be defined anywhere on this window. 70 00:06:32,670 --> 00:06:34,110 So that is a random one. 71 00:06:34,170 --> 00:06:42,320 That's why I included here random here so we will define it's coded x and y coordinates both randomly 72 00:06:42,590 --> 00:06:46,980 and then whatever we get there will please deliver that particular position. 73 00:06:47,300 --> 00:06:51,750 So we will use set X and set Vikram on. 74 00:06:52,040 --> 00:07:00,290 So leave those set X and leave not set y that will threaten nameless said the coordinates x and y and 75 00:07:00,290 --> 00:07:07,770 to generate a random number just random already because we haven't boarded this on his army note ran 76 00:07:07,840 --> 00:07:19,680 into and provide the limit say minus two hundred to two hundred and same for the VI axis they had this 77 00:07:19,680 --> 00:07:30,770 one and whenever I get any of this position we got the live coordinate x and y and at that point I just 78 00:07:30,770 --> 00:07:33,920 showed the total that we had this. 79 00:07:34,610 --> 00:07:39,760 So it will just find decoding it and showed it total by first hiding the original one. 80 00:07:40,550 --> 00:07:44,110 So that's about these two functions outside window in place. 81 00:07:44,210 --> 00:07:49,340 I hope you get all both of these and they're very easy to understand and create. 82 00:07:49,400 --> 00:07:52,050 Now we will move to these two in the next video. 83 00:07:52,190 --> 00:07:53,300 So thanks for watching. 84 00:07:53,300 --> 00:07:54,260 See you in the next video.