Hey everyone.
So now we are nearly done with the program and we just need to add some few interactive keys here so
that the will get to be local listeners and move according to us.
So for that one I'm adding a few more keys here on Key and beginning with say moving up and define a
function for that one.
Same move up that we did not have defined yet but defined after this.
And the key for that one is up.
So except this base in most of the keys we have lost larger capital than the segments more than we have.
Again this one's so now that one copy and the one on key Pence's copy this one command sea bass dipped
thrice the second one is say move down and for that one we use the key down and the third one see move
the scope left for that one we have capital and left.
And the last one is move underscored right.
And for that one we are going to have right maybe all already 40s and their motion.
How would you define that what will happen on pressing these keys.
So first one I have define
move underscored up medial so for keys motion you need to define similarly all the functions for these
and defining the keys functions are really really very easy but one thing you need to focus.
Just imagine I have this that here and the imagine this one is my caterpillar I'm moving up for direction
so one thing here I can agree to rest my path.
The Caterpillar did not move in that direction like moving forward then it will not move like this but
and the available positions at this condition like when this one is moving a foot it has only left and
right similarly when this one is moving like this one then it has only left and right so the thing here
is if I move want to move my caterpillar in up direction then then this one will move in a direction
like when I'm moving downward.
It cannot go up and when this one is already moving offered then they are not required to move that
money.
But so the two only possible conditions are when I'm moving in the right direction then I can move up
and when I'm moving left direction I can move.
But let me show you that one with the Caterpillar would be like so this one ghetto below would be why
we have a caterpillar.
So now I want to move up I can go up there.
But now when I'm already going up so I cannot move in the backward direction right now where I'm already
moving a virtual how I can move up again I can do this one only to position condition in this one.
So now up and even this one up.
So these are the two conditions in which I can go up and the conditions they are are.
If Caterpillar not heading I can use heading so this is metal you can actually find the alignment or
see angle of the particular motion or any turtle.
So if that angle equal to zero degree or that is moving actually in the right direction.
So that is actually what zero angle when we have a straight horizontal line moving in the right direction
or pointed in the right direction or Caterpillar road heading
this one equal to 180 degrees.
It means it's moving in left direction.
So in these cases what will I do.
I will just Caterpillar not set heading.
I will change the heading only so set heading.
And I will set this heading to 90 degree a.
Hope you get this one because this is the only thing you understand.
And only once you need to understand after this one you will never require this one to get focus on.
Just go through this one again if you do not understand this one I will again explain this one here
in the down so move underscored down
now in which positions I can move down when I'm moving either forward or even better then only I can
move No so if might get to below.
Again these two same commands heading with these two now we have.
So then this one is heading in zero angle and 180 degrees.
So what are zero wanted to do the right and left.
So in this case I will make my caterpillar head heading sorry Do not Ninety 90 is going to be consider
say.
But this line this and this.
So if this is my angle 0.
This terminal boundary then this one is my angle 90.
So in 92 to make this one up but with left also.
And this is referred to as a 0 degree angle always.
So if I want my caterpillar in downward direction.
So what will I do.
90 90 90 180 and 90 to 70.
So I will move my heading to 270 decrease so in that way I will have distraction.
If you want to Caterpillar moving like this V diagonally then you can also align angles like 45 135
to 35.
In that case it will move in those directions and no.
Same for the same move up.
So we have divided up moves right so in light when I can move in right direction say my caterpillar
again we need you.
So if I'm moving in a vacation I can move right.
If I'm moving in downward again I can move in right.
But when I'm moving in left direction I cannot move in the right direction.
Even pressing one and when I'm already moving in the right direction I can hold I can move in that one
because I'm already in that direction so the only directions you can change with right are the 90 degree
that I'm already in 90 degree or delay.
DONVAN now is 270 degree.
So remember these 0 is always right 90s a when it is left and to 70s modem.
So in that case to move that one in right just set the heading to zero degrees because zero is four
right now.
Copy this whole base to tail and define the left so the condition for left motion are also these 90
and 270 because I can move left when I am either up or either down but the left angle is one hundred
and eighty degrees.
So this is all about the keys that how you can use keys and how you can define them motion and I hope
you go to that one.
The main function of this one is heading and set heading.
Now let with driver program so maybe this one they will best start I'm getting this one going up direction
perfectly left down right.
So I'm moving perfectly fine.
Only one thing I'm getting here this goes in center.
So let me check that also why this one is happening maybe you'd do any better.
Come on we left there.
So I have taken belief in my school increases to 10 spirit and Lantana also increases and leaf is also
working completely fine.
So all of these things are working completely fine.
Just this goal is something bothering us.
So now let me check that by hitting ball.
So game over but this court is here.
So now that we check that what's happening with this ball.
So that's actually displaced court.
And here this is already.
Right so here it is.
So we have defined the coordinates x invite but we forget something like we are defining the position
that we need to assign that X Y position.
So just scored underscored.
Total note said position.
And this just X Y labial say this one run it again.
So this is something I feel that way at that particular position because of defining this come on a
line right before that.
So sort of all that fun.
And let me check of a program maybe.
So now we have a low score at proper position and now let's check the booking.
We have the caterpillar moving perfectly.
Now the leaf oh let go
there we have everything working fine.
So here we have a caterpillar working completely fine in my game is over.
And I hope you enjoyed this fun.
So thanks for watching.
In the next module we will build different projects.
So see the.