1 00:00:05,770 --> 00:00:07,010 Hey everyone. 2 00:00:07,160 --> 00:00:11,700 So now we have defined all the interface items and we will move all of working now. 3 00:00:11,990 --> 00:00:16,200 So first of all instead of writing the code in one line I'm going to write in functions. 4 00:00:16,490 --> 00:00:18,400 So I will define two functions here. 5 00:00:18,620 --> 00:00:23,130 That is related with the like creating the ACT and the motion of the egg. 6 00:00:23,180 --> 00:00:25,390 That how it is getting done. 7 00:00:26,350 --> 00:00:32,530 So first of all before moving to that one I need you to remember these things that we have created while 8 00:00:32,530 --> 00:00:33,910 we are defining day. 9 00:00:34,060 --> 00:00:37,430 That is the color cycle for the changing colors of egg. 10 00:00:38,140 --> 00:00:40,840 Then we have the egg grid and its height. 11 00:00:40,840 --> 00:00:46,360 After that when this go would you have required right now we have the speed and the interval. 12 00:00:46,780 --> 00:00:51,640 And these are debatable I have told you that I will tell that by their five hundred and four thousand 13 00:00:51,640 --> 00:00:52,310 when we need them. 14 00:00:52,810 --> 00:00:59,540 So the reason for that one is in many situations mostly while we are working with emotion and maybe 15 00:00:59,540 --> 00:01:05,870 in Python or in every programming or even when we are working with the microcontrollers the time intervals 16 00:01:05,960 --> 00:01:08,930 are taken in milliseconds not in seconds. 17 00:01:08,930 --> 00:01:15,530 However when we use the time function that is not there right now we are only used seconds there while 18 00:01:15,550 --> 00:01:17,330 we are finding that sleep. 19 00:01:17,630 --> 00:01:20,290 But here we require that things in milliseconds. 20 00:01:20,300 --> 00:01:24,700 Let me show you that one when I run the program and I have the saying. 21 00:01:24,770 --> 00:01:28,010 So if you count to four let the add one for David. 22 00:01:28,310 --> 00:01:31,910 One two three and four. 23 00:01:31,910 --> 00:01:33,250 There we go. 24 00:01:33,260 --> 00:01:45,080 So after each four seconds is the appeal of new so that is this interval and the speed again if you 25 00:01:45,080 --> 00:01:48,680 notice these X then moving down then not actually moving down. 26 00:01:49,100 --> 00:01:55,410 They are just changing their positions after e.g. 2.5 second because falling is continuous because they 27 00:01:55,480 --> 00:01:58,610 are taking discontinuity breaks. 28 00:01:58,730 --> 00:02:03,960 So I hope you get these two variables right now that what the after that one. 29 00:02:04,470 --> 00:02:12,880 Let me move to work creating it first of all I I'm taking at least half an empty list of eggs you and 30 00:02:13,110 --> 00:02:24,130 now here I will define a function that will create X go knowing this one how will it create egg it just 31 00:02:24,130 --> 00:02:30,890 imagine this but this white boundary and if I run my catch it would be like and notice one thing when 32 00:02:30,890 --> 00:02:37,420 the eggs are falling what the thing here is they have a fixed height and it and they're falling from 33 00:02:37,420 --> 00:02:38,410 the same height. 34 00:02:38,410 --> 00:02:44,040 What differences is they're falling at different positions say that is actually the difference in x 35 00:02:44,090 --> 00:02:45,890 sexes like this one is beginning. 36 00:02:45,910 --> 00:02:46,660 That is in the end. 37 00:02:46,660 --> 00:02:56,310 They are in middle so the thing here is like if this is that thing from their falling then this is from 38 00:02:56,310 --> 00:02:59,550 a specific height from the to say 40. 39 00:02:59,550 --> 00:03:04,440 So they are all falling from the height 40 foot little enough of that one. 40 00:03:04,440 --> 00:03:06,360 Some are falling maybe at this point. 41 00:03:06,430 --> 00:03:07,070 Green. 42 00:03:07,190 --> 00:03:12,780 Some are falling from this star like wonder why some are falling like from this Wi-Fi signal. 43 00:03:12,810 --> 00:03:18,180 Some are from battery and that is actually defend for each of these. 44 00:03:18,270 --> 00:03:19,080 So what. 45 00:03:19,080 --> 00:03:21,020 The thing here is I am. 46 00:03:21,210 --> 00:03:30,930 I want to tell you that that the access is it different from each of these so that is something I am. 47 00:03:31,130 --> 00:03:37,700 I'm going to take x is equal to Rand range between 10 to 740. 48 00:03:37,940 --> 00:03:38,870 So what will it do. 49 00:03:38,870 --> 00:03:44,620 It will select random positions of X from 10 to 740. 50 00:03:44,870 --> 00:03:49,770 So it can be anywhere on this axis and then another variable right. 51 00:03:49,880 --> 00:03:57,320 That is a fixed value me because they are falling from the same height every of these after that one. 52 00:03:57,620 --> 00:03:59,060 What about the end. 53 00:03:59,170 --> 00:04:05,750 Now but if this is falling from this point this point I have a fixed height and weight of the egg but 54 00:04:05,750 --> 00:04:08,030 the program did not know that from there. 55 00:04:08,780 --> 00:04:11,740 Maybe the program consider that one here and create egg here. 56 00:04:12,140 --> 00:04:19,090 Maybe at this keypad or maybe in the middle there is something programmed will not understand. 57 00:04:19,130 --> 00:04:21,920 So how will Bill make that understand. 58 00:04:21,920 --> 00:04:23,000 Let me show you that one here. 59 00:04:23,300 --> 00:04:31,960 So first of all a new variable and that is going to be just seed or create underscored all because he's 60 00:04:31,970 --> 00:04:33,110 actually normal. 61 00:04:33,350 --> 00:04:37,260 And in that one we need to provide for positions starting. 62 00:04:37,280 --> 00:04:48,580 That is X and Y and the end positions there will be something like egg width and egg height. 63 00:04:48,710 --> 00:04:54,410 So if his students are thinking that this is enough we have defined X invite and the egg with an egg 64 00:04:54,410 --> 00:04:55,070 height. 65 00:04:55,070 --> 00:05:02,710 And now if this is the initial egg x value then the program will automatically consider this plus. 66 00:05:03,170 --> 00:05:05,360 And that will be my vehicle. 67 00:05:05,780 --> 00:05:15,700 But the thing notice here need to be notice damp is like if this is my VIT say this is totally approximating 68 00:05:16,270 --> 00:05:23,130 and my X originates here then you are thinking that the output is going to be from this point. 69 00:05:23,170 --> 00:05:28,710 Plus this weight but what will happen actually there is this is the initial point. 70 00:05:29,110 --> 00:05:31,930 And your weight is going to be start from this point. 71 00:05:32,800 --> 00:05:39,640 So that is something here but you have x values here and you are accepting the output like this oval 72 00:05:39,640 --> 00:05:41,370 here. 73 00:05:41,370 --> 00:05:45,300 So what I need to do here I need to add the x value also. 74 00:05:45,750 --> 00:05:53,610 Like if this if my eggs are this gross symbol then my end point for that is this gross symbol again 75 00:05:53,640 --> 00:05:55,740 x plus the vehicle. 76 00:05:56,250 --> 00:05:59,530 So I will reach up to him and this will begin my egg. 77 00:06:00,450 --> 00:06:04,170 Similarly height will be VI plus egg height. 78 00:06:04,380 --> 00:06:06,260 However divide is fixed 40. 79 00:06:06,300 --> 00:06:07,890 You can also do 40 plus. 80 00:06:08,020 --> 00:06:09,990 I let you go. 81 00:06:10,170 --> 00:06:11,910 So I hope you understand these two. 82 00:06:11,910 --> 00:06:18,950 And if you did not then just ask me after that one that we talk about big color feet so how we can feel 83 00:06:18,950 --> 00:06:21,600 that one just by next of the cycle. 84 00:06:22,200 --> 00:06:29,260 So just call next and color cycle maybe go and in-laws just activate equal to zero. 85 00:06:29,280 --> 00:06:31,330 That is the boundary. 86 00:06:31,430 --> 00:06:32,790 Now we have created the egg. 87 00:06:33,720 --> 00:06:37,920 What we will do now we need a record of these eggs. 88 00:06:37,980 --> 00:06:39,060 So what will I do. 89 00:06:39,150 --> 00:06:40,520 I will take this list here. 90 00:06:40,560 --> 00:06:46,490 Eggs and abandon this one. 91 00:06:46,500 --> 00:06:47,350 We didn't need one. 92 00:06:48,270 --> 00:06:56,720 So bright new egg so however slowly whenever the new egg is created it will be appended in the original 93 00:06:56,840 --> 00:06:57,970 egg list. 94 00:06:58,010 --> 00:07:01,590 So there we have the old eggs in the eggs. 95 00:07:02,270 --> 00:07:05,510 And now at this point we are done with creating an egg. 96 00:07:06,020 --> 00:07:07,520 What about creating the anatomy. 97 00:07:07,850 --> 00:07:10,850 So just call the function again inside of the function. 98 00:07:12,140 --> 00:07:14,200 So that is also very easy. 99 00:07:14,210 --> 00:07:17,780 You need to just create underscored eggs again. 100 00:07:18,410 --> 00:07:20,210 So create underscored eggs. 101 00:07:20,450 --> 00:07:27,170 But what you need to focus here if you do this one then the eggs are creating just this one then this 102 00:07:27,170 --> 00:07:29,540 one this one this one without any endeavor. 103 00:07:30,740 --> 00:07:36,440 So what would apply here require fixed interval and how we will do that one window. 104 00:07:36,500 --> 00:07:41,210 After that after this time here it will first Boston deliver. 105 00:07:41,210 --> 00:07:42,360 That is egg in Dover. 106 00:07:43,490 --> 00:07:46,130 And after this into that that is four seconds. 107 00:07:46,280 --> 00:07:50,270 Call again the function create X bagel. 108 00:07:50,510 --> 00:07:54,210 So this is how you can create a new wing. 109 00:07:54,290 --> 00:08:00,230 I hope you understand this one because I have tried to make you understand this one in very easy but 110 00:08:00,230 --> 00:08:08,480 if you still have any problems then again just ask me after that when we need to define move. 111 00:08:08,510 --> 00:08:12,960 Eggs so move underscored eggs. 112 00:08:13,020 --> 00:08:17,020 There you go and in this one how will I define. 113 00:08:17,030 --> 00:08:20,270 The motion is if you consider all the x. 114 00:08:20,300 --> 00:08:23,940 They're not actually moving they're just changing they're all full coordinates. 115 00:08:24,300 --> 00:08:31,980 So second thing I noticed here is now I have three eggs and they're all moving at the same time and 116 00:08:32,000 --> 00:08:35,540 the same distance and same speed. 117 00:08:35,580 --> 00:08:36,840 So what will I do here. 118 00:08:37,230 --> 00:08:41,340 I will take all the exit so for egg in eggs. 119 00:08:41,850 --> 00:08:45,030 So it will work for the every egg available in the eggs. 120 00:08:45,070 --> 00:08:47,330 That how many I have at their present day. 121 00:08:47,610 --> 00:08:54,690 What will I do I will take all the coordinates for each of the eggs as egg underscored X egg underscore 122 00:08:55,180 --> 00:09:03,150 why that egg underscored x2 and egg under. 123 00:09:03,180 --> 00:09:11,650 Why do you and provide them the values of coordinates for the particular egg. 124 00:09:11,670 --> 00:09:13,140 Let me go now. 125 00:09:13,210 --> 00:09:19,650 These are the coordinates with Egypt and then I will move all of these by considering their coordinates 126 00:09:19,650 --> 00:09:22,440 Steidle with a distance. 127 00:09:23,340 --> 00:09:26,370 So I have the coordinates of each egg and I move them to the distance. 128 00:09:26,380 --> 00:09:33,020 Then and after that one day will move until they dropped or touches data and then they touch the ground. 129 00:09:33,230 --> 00:09:40,800 Is when are the bottom point like this point this morning. 130 00:09:40,870 --> 00:09:47,260 Get that with this one and when this one pitch with this one is like then the Y two became larger than 131 00:09:47,260 --> 00:09:49,690 the height of this canvas. 132 00:09:49,690 --> 00:09:50,200 So 133 00:09:53,050 --> 00:10:01,830 if we will take divide 2 so eg underscore y2 greater than the canvas height. 134 00:10:02,580 --> 00:10:08,020 So in that case what will happen the egg is drop and we will not defined the drop here. 135 00:10:08,040 --> 00:10:14,180 We will take a So we call a function egg underscored drop that we have not defined yet but we will define 136 00:10:14,190 --> 00:10:19,160 the next video and we will just call that one for the particular egg. 137 00:10:19,560 --> 00:10:24,780 Not all the eggs will be dropped just that one that is hitting the ground at that point. 138 00:10:24,780 --> 00:10:32,470 After that when this is about hitting this one and now at this point we have moved all the eggs with 139 00:10:32,470 --> 00:10:39,420 the distance then now they will just move once to move then again and again. 140 00:10:39,470 --> 00:10:47,780 I need to call this function inside itself again and again and with interval of speed so windowed after 141 00:10:47,930 --> 00:11:00,490 the x speed and the school's speed again move the X so move underscored X so I hope you get this one 142 00:11:00,490 --> 00:11:03,790 also because this is more risky than the above. 143 00:11:04,560 --> 00:11:10,810 Now we have defined creation of facts and emotional things in the next video we'll consider that what 144 00:11:10,810 --> 00:11:11,420 will happen. 145 00:11:11,470 --> 00:11:15,070 When the egg is drop and how it will affect the lights. 146 00:11:15,220 --> 00:11:16,430 So thanks for watching. 147 00:11:16,500 --> 00:11:18,300 Its in the next video.