Hey everyone.
So now we have defined all the interface items and we will move all of working now.
So first of all instead of writing the code in one line I'm going to write in functions.
So I will define two functions here.
That is related with the like creating the ACT and the motion of the egg.
That how it is getting done.
So first of all before moving to that one I need you to remember these things that we have created while
we are defining day.
That is the color cycle for the changing colors of egg.
Then we have the egg grid and its height.
After that when this go would you have required right now we have the speed and the interval.
And these are debatable I have told you that I will tell that by their five hundred and four thousand
when we need them.
So the reason for that one is in many situations mostly while we are working with emotion and maybe
in Python or in every programming or even when we are working with the microcontrollers the time intervals
are taken in milliseconds not in seconds.
However when we use the time function that is not there right now we are only used seconds there while
we are finding that sleep.
But here we require that things in milliseconds.
Let me show you that one when I run the program and I have the saying.
So if you count to four let the add one for David.
One two three and four.
There we go.
So after each four seconds is the appeal of new so that is this interval and the speed again if you
notice these X then moving down then not actually moving down.
They are just changing their positions after e.g. 2.5 second because falling is continuous because they
are taking discontinuity breaks.
So I hope you get these two variables right now that what the after that one.
Let me move to work creating it first of all I I'm taking at least half an empty list of eggs you and
now here I will define a function that will create X go knowing this one how will it create egg it just
imagine this but this white boundary and if I run my catch it would be like and notice one thing when
the eggs are falling what the thing here is they have a fixed height and it and they're falling from
the same height.
What differences is they're falling at different positions say that is actually the difference in x
sexes like this one is beginning.
That is in the end.
They are in middle so the thing here is like if this is that thing from their falling then this is from
a specific height from the to say 40.
So they are all falling from the height 40 foot little enough of that one.
Some are falling maybe at this point.
Green.
Some are falling from this star like wonder why some are falling like from this Wi-Fi signal.
Some are from battery and that is actually defend for each of these.
So what.
The thing here is I am.
I want to tell you that that the access is it different from each of these so that is something I am.
I'm going to take x is equal to Rand range between 10 to 740.
So what will it do.
It will select random positions of X from 10 to 740.
So it can be anywhere on this axis and then another variable right.
That is a fixed value me because they are falling from the same height every of these after that one.
What about the end.
Now but if this is falling from this point this point I have a fixed height and weight of the egg but
the program did not know that from there.
Maybe the program consider that one here and create egg here.
Maybe at this keypad or maybe in the middle there is something programmed will not understand.
So how will Bill make that understand.
Let me show you that one here.
So first of all a new variable and that is going to be just seed or create underscored all because he's
actually normal.
And in that one we need to provide for positions starting.
That is X and Y and the end positions there will be something like egg width and egg height.
So if his students are thinking that this is enough we have defined X invite and the egg with an egg
height.
And now if this is the initial egg x value then the program will automatically consider this plus.
And that will be my vehicle.
But the thing notice here need to be notice damp is like if this is my VIT say this is totally approximating
and my X originates here then you are thinking that the output is going to be from this point.
Plus this weight but what will happen actually there is this is the initial point.
And your weight is going to be start from this point.
So that is something here but you have x values here and you are accepting the output like this oval
here.
So what I need to do here I need to add the x value also.
Like if this if my eggs are this gross symbol then my end point for that is this gross symbol again
x plus the vehicle.
So I will reach up to him and this will begin my egg.
Similarly height will be VI plus egg height.
However divide is fixed 40.
You can also do 40 plus.
I let you go.
So I hope you understand these two.
And if you did not then just ask me after that one that we talk about big color feet so how we can feel
that one just by next of the cycle.
So just call next and color cycle maybe go and in-laws just activate equal to zero.
That is the boundary.
Now we have created the egg.
What we will do now we need a record of these eggs.
So what will I do.
I will take this list here.
Eggs and abandon this one.
We didn't need one.
So bright new egg so however slowly whenever the new egg is created it will be appended in the original
egg list.
So there we have the old eggs in the eggs.
And now at this point we are done with creating an egg.
What about creating the anatomy.
So just call the function again inside of the function.
So that is also very easy.
You need to just create underscored eggs again.
So create underscored eggs.
But what you need to focus here if you do this one then the eggs are creating just this one then this
one this one this one without any endeavor.
So what would apply here require fixed interval and how we will do that one window.
After that after this time here it will first Boston deliver.
That is egg in Dover.
And after this into that that is four seconds.
Call again the function create X bagel.
So this is how you can create a new wing.
I hope you understand this one because I have tried to make you understand this one in very easy but
if you still have any problems then again just ask me after that when we need to define move.
Eggs so move underscored eggs.
There you go and in this one how will I define.
The motion is if you consider all the x.
They're not actually moving they're just changing they're all full coordinates.
So second thing I noticed here is now I have three eggs and they're all moving at the same time and
the same distance and same speed.
So what will I do here.
I will take all the exit so for egg in eggs.
So it will work for the every egg available in the eggs.
That how many I have at their present day.
What will I do I will take all the coordinates for each of the eggs as egg underscored X egg underscore
why that egg underscored x2 and egg under.
Why do you and provide them the values of coordinates for the particular egg.
Let me go now.
These are the coordinates with Egypt and then I will move all of these by considering their coordinates
Steidle with a distance.
So I have the coordinates of each egg and I move them to the distance.
Then and after that one day will move until they dropped or touches data and then they touch the ground.
Is when are the bottom point like this point this morning.
Get that with this one and when this one pitch with this one is like then the Y two became larger than
the height of this canvas.
So
if we will take divide 2 so eg underscore y2 greater than the canvas height.
So in that case what will happen the egg is drop and we will not defined the drop here.
We will take a So we call a function egg underscored drop that we have not defined yet but we will define
the next video and we will just call that one for the particular egg.
Not all the eggs will be dropped just that one that is hitting the ground at that point.
After that when this is about hitting this one and now at this point we have moved all the eggs with
the distance then now they will just move once to move then again and again.
I need to call this function inside itself again and again and with interval of speed so windowed after
the x speed and the school's speed again move the X so move underscored X so I hope you get this one
also because this is more risky than the above.
Now we have defined creation of facts and emotional things in the next video we'll consider that what
will happen.
When the egg is drop and how it will affect the lights.
So thanks for watching.
Its in the next video.