Hey everyone.
So in this video we create a moving turtle that we move on disfigured when we look like something here.
This turtle moving here and there randomly and changing its direction mindset.
So few things notice here like it is moving in a fixed boundary.
And second is its motion that is random any way it can move.
So these things we need to focus and let begin with.
So let me just clear this one.
After that one we will import turtle as deep deep temperature.
We go after that one will import random as our default random motion.
Then we will import dying as D.A. for a while.
And after that one just at the I don't sleep safe for three seconds.
That's enough I blew after that one.
If you talk about the turtle and it seems that the greeting the turtle is very hard.
People's debts animated figure but that is a by default figure.
So you can just simply create this one date don't shape and Bosnia just maybe.
If you done this one day we have a turtle here and that is look like the actual one after that one.
The one we have noticed is green and this one is black.
So we will make this one green so we don't feel color and pass they are green.
Now if you run that one maybe have a green Toda after that one.
If we talk about the background color then in the demo that will be a black.
So make this one black and now if you run that one you will have a black Bongo background with this
turtle here so we are done with this thing.
Just last speed of Denver so totally slow.
So bossy a slow after that when we will move to defining the boundaries and defining the motion.
So let's begin with that one.
First the boundary that we have.
That one is inside underscore window denoting the inside window.
So what actually I will do here.
I will define right left top and bottom limits so that that will not get out of debt.
And how will I define that one as you know that these center this point like this one is the center
of the window when that appears here a total traffic.
Then here we have some distance on the left on the right on the top and bottom.
So what we will do well will first get the left and right the bottom distances and then make a boundary
of taking like hundred from distance so that it will not get too boundary.
Let me show you that one then you will understand it better.
So first of all I will define limit and not only limit left limit there you and how would I define that
one.
First of all getting the size of the window is very easy.
You just have to do b short window underscore would forward and land for the height.
So I'm just taking the food out of Declan and pasta Pence is there.
So that's how you can get the length of your window.
Now the left portion of this one is the half of the total.
Like if I am going to point the window then the half of that is the left one because we have the center
at the center of the window in case of total graphics and the left distance is also negative.
So this is actually the available land at the left side.
What will I do.
I will make a hundred from the corner like if I assume this one is a hundred.
So this is total minus hundred.
So what will I do.
I will subtract minus from this one but actually the distance is in negative so I need to add here hundred
to reduce from the boundary a distance of a hundred pixels.
That's about the limit.
Now it is very easy to add.
Others say this one right.
No I wrote it straight.
There you go.
This is going to be positive.
So I need to subtract hundred from that but I think you understand this now.
Then I have the top limit and that is going to be actually the height not do it.
Also that is actually positive so I need to subtract this one because upside is positive and also also
display and if I talk about the bottom one that is this one bottom that is actually going to be a negative
distance so I need to add hundred.
I hope you understand this one creating the limit.
Now I will take X and Y and these are the actual positions of a coaster at that particular location
or sale a total.
And how will I get them.
Just simply did not position and fences.
That's how I can get the position of x and y.
Now I have the position of X and Y and the limits.
What will I do now.
I will take a variable inside that tells me that actually the total is inside of the window or not.
If it is inside the window then make the program run a device comeback and that will be actually what
does inside of me.
That is it is greater than the left distance lower than the right distance because if it will be somewhere
around d that I am moving might cause a hand.
So it's actually greater than the left one and lower than the right one.
Similarly greater than the bottom less than the right.
So just left underscored and this will be going to be a boolean.
Actually it is just only true or false that it's actually inside the window.
Nope then false.
So how will I define that one.
So it will X in that case the positions x is greater than X limit and less then right limit.
So here we have right limit and our via greater than the bottom less than the top so bottom limit and
then less than the top limit.
Let me go.
I hope you understand this well because this is very easy and clear.
And then just return inside.
Maybe go after that one.
We will define a move function.
Define move.
This will actually move a turtle or move under scored until is much better.
That name has no effect.
After that one we will check here whether it is inside the window or not.
So if it is inside of the window then it will actually move over a turtle as it will take the turtle
back to the window.
So how will I do that one.
First of all when it is inside the window so I will actually do the dot right and then I will pass just
an angle at which it has to move and then I will make it run for what so forward say two hundred.
You can take any distance and a task for you make this distance also.
Now if I specified the angle by my own the two will always move with those particular angle but I don't
need that one.
So what will I do inside the if condition.
I will define the angle as a random value between zero to one hundred and eighty because there are three
possible angles so angle will be.
If you remember creating the random values we have this an army R.
Don't rend it and that will actually be in between zero to one hundred and eighty.
So by this I will get a random value that random will be its move angle and then it will move forward.
So similarly you have to make this forward distance is a random value.
So I hope you will get that one.
Just a distance variable and convert that also into random after that one if it is not inside the vendor.
My mistake could get out of that one.
So in that case just move backward with see a value 200 so that it will get making a lot no.
After that when I need to call the functions so why it's true while it's inside that one so in that
case just move title and positive balances maybe go whenever that is true.
Just call it function.
Remove that one and those fingers broke them.
Maybe go so it's actually moving two hundred is tense and trend of values.
I hope this one is very easy and also easy to understand.
So you can also play with this one much wanting to play just look at it as if you want to make this
one random just you need to pass here said best distance R B don't Rand int take between say from 50
to 300 and parse this one here.
List save and now when you land that 1 you will get this one moving with different distances
so that's how you're gonna create this one but easily and also in that case make the backward distance
to maximum 300 so that you do not get lost.
So this is the code you will also get to check the errors whether you have any or not.
And also this time is not required now.
So this is all about this one and about the total graphics more you will understand the motion well
we work on the projects we are required to move the figures with the keypad.
So wait for that one.
I hope you are excited with that.
So thanks for watching.
See you later.