1 00:00:05,610 --> 00:00:06,810 Hey everyone. 2 00:00:06,890 --> 00:00:13,690 So in this video we create a moving turtle that we move on disfigured when we look like something here. 3 00:00:13,730 --> 00:00:18,410 This turtle moving here and there randomly and changing its direction mindset. 4 00:00:19,490 --> 00:00:24,530 So few things notice here like it is moving in a fixed boundary. 5 00:00:24,530 --> 00:00:27,800 And second is its motion that is random any way it can move. 6 00:00:28,880 --> 00:00:32,820 So these things we need to focus and let begin with. 7 00:00:33,800 --> 00:00:40,140 So let me just clear this one. 8 00:00:40,770 --> 00:00:47,890 After that one we will import turtle as deep deep temperature. 9 00:00:48,240 --> 00:00:55,290 We go after that one will import random as our default random motion. 10 00:00:55,290 --> 00:01:00,450 Then we will import dying as D.A. for a while. 11 00:01:01,740 --> 00:01:08,460 And after that one just at the I don't sleep safe for three seconds. 12 00:01:08,460 --> 00:01:11,310 That's enough I blew after that one. 13 00:01:12,470 --> 00:01:17,440 If you talk about the turtle and it seems that the greeting the turtle is very hard. 14 00:01:17,480 --> 00:01:22,010 People's debts animated figure but that is a by default figure. 15 00:01:22,670 --> 00:01:32,400 So you can just simply create this one date don't shape and Bosnia just maybe. 16 00:01:33,560 --> 00:01:44,070 If you done this one day we have a turtle here and that is look like the actual one after that one. 17 00:01:45,210 --> 00:01:48,470 The one we have noticed is green and this one is black. 18 00:01:48,540 --> 00:01:56,130 So we will make this one green so we don't feel color and pass they are green. 19 00:01:56,130 --> 00:02:02,860 Now if you run that one maybe have a green Toda after that one. 20 00:02:03,600 --> 00:02:09,280 If we talk about the background color then in the demo that will be a black. 21 00:02:09,280 --> 00:02:16,610 So make this one black and now if you run that one you will have a black Bongo background with this 22 00:02:16,610 --> 00:02:19,900 turtle here so we are done with this thing. 23 00:02:19,920 --> 00:02:26,670 Just last speed of Denver so totally slow. 24 00:02:26,670 --> 00:02:36,220 So bossy a slow after that when we will move to defining the boundaries and defining the motion. 25 00:02:36,280 --> 00:02:38,380 So let's begin with that one. 26 00:02:38,730 --> 00:02:40,390 First the boundary that we have. 27 00:02:40,390 --> 00:02:46,290 That one is inside underscore window denoting the inside window. 28 00:02:46,920 --> 00:02:48,520 So what actually I will do here. 29 00:02:48,970 --> 00:02:53,560 I will define right left top and bottom limits so that that will not get out of debt. 30 00:02:54,280 --> 00:03:00,590 And how will I define that one as you know that these center this point like this one is the center 31 00:03:00,590 --> 00:03:03,790 of the window when that appears here a total traffic. 32 00:03:04,030 --> 00:03:09,430 Then here we have some distance on the left on the right on the top and bottom. 33 00:03:09,430 --> 00:03:16,690 So what we will do well will first get the left and right the bottom distances and then make a boundary 34 00:03:16,690 --> 00:03:22,410 of taking like hundred from distance so that it will not get too boundary. 35 00:03:22,420 --> 00:03:24,580 Let me show you that one then you will understand it better. 36 00:03:24,970 --> 00:03:33,330 So first of all I will define limit and not only limit left limit there you and how would I define that 37 00:03:33,330 --> 00:03:34,620 one. 38 00:03:34,680 --> 00:03:37,830 First of all getting the size of the window is very easy. 39 00:03:37,830 --> 00:03:45,180 You just have to do b short window underscore would forward and land for the height. 40 00:03:45,750 --> 00:03:50,580 So I'm just taking the food out of Declan and pasta Pence is there. 41 00:03:50,730 --> 00:03:56,240 So that's how you can get the length of your window. 42 00:03:56,730 --> 00:04:02,410 Now the left portion of this one is the half of the total. 43 00:04:02,560 --> 00:04:08,290 Like if I am going to point the window then the half of that is the left one because we have the center 44 00:04:08,770 --> 00:04:16,360 at the center of the window in case of total graphics and the left distance is also negative. 45 00:04:17,110 --> 00:04:22,250 So this is actually the available land at the left side. 46 00:04:22,300 --> 00:04:23,480 What will I do. 47 00:04:23,530 --> 00:04:29,230 I will make a hundred from the corner like if I assume this one is a hundred. 48 00:04:29,740 --> 00:04:32,160 So this is total minus hundred. 49 00:04:32,260 --> 00:04:33,100 So what will I do. 50 00:04:33,100 --> 00:04:39,520 I will subtract minus from this one but actually the distance is in negative so I need to add here hundred 51 00:04:39,880 --> 00:04:43,960 to reduce from the boundary a distance of a hundred pixels. 52 00:04:43,960 --> 00:04:45,110 That's about the limit. 53 00:04:45,130 --> 00:04:46,830 Now it is very easy to add. 54 00:04:46,930 --> 00:04:50,410 Others say this one right. 55 00:04:50,570 --> 00:04:52,310 No I wrote it straight. 56 00:04:52,960 --> 00:04:54,070 There you go. 57 00:04:54,070 --> 00:04:55,510 This is going to be positive. 58 00:04:55,510 --> 00:05:00,430 So I need to subtract hundred from that but I think you understand this now. 59 00:05:01,500 --> 00:05:08,740 Then I have the top limit and that is going to be actually the height not do it. 60 00:05:08,800 --> 00:05:17,490 Also that is actually positive so I need to subtract this one because upside is positive and also also 61 00:05:17,500 --> 00:05:28,520 display and if I talk about the bottom one that is this one bottom that is actually going to be a negative 62 00:05:28,550 --> 00:05:32,450 distance so I need to add hundred. 63 00:05:32,890 --> 00:05:35,720 I hope you understand this one creating the limit. 64 00:05:35,780 --> 00:05:43,540 Now I will take X and Y and these are the actual positions of a coaster at that particular location 65 00:05:43,570 --> 00:05:44,650 or sale a total. 66 00:05:45,100 --> 00:05:46,590 And how will I get them. 67 00:05:46,630 --> 00:05:49,620 Just simply did not position and fences. 68 00:05:49,630 --> 00:05:52,560 That's how I can get the position of x and y. 69 00:05:52,660 --> 00:05:55,940 Now I have the position of X and Y and the limits. 70 00:05:56,110 --> 00:05:57,030 What will I do now. 71 00:05:57,040 --> 00:06:03,540 I will take a variable inside that tells me that actually the total is inside of the window or not. 72 00:06:03,760 --> 00:06:12,490 If it is inside the window then make the program run a device comeback and that will be actually what 73 00:06:12,490 --> 00:06:13,420 does inside of me. 74 00:06:13,420 --> 00:06:21,100 That is it is greater than the left distance lower than the right distance because if it will be somewhere 75 00:06:22,070 --> 00:06:25,130 around d that I am moving might cause a hand. 76 00:06:25,730 --> 00:06:29,030 So it's actually greater than the left one and lower than the right one. 77 00:06:29,060 --> 00:06:32,420 Similarly greater than the bottom less than the right. 78 00:06:32,780 --> 00:06:38,960 So just left underscored and this will be going to be a boolean. 79 00:06:38,960 --> 00:06:43,870 Actually it is just only true or false that it's actually inside the window. 80 00:06:44,070 --> 00:06:45,440 Nope then false. 81 00:06:46,130 --> 00:06:47,660 So how will I define that one. 82 00:06:47,750 --> 00:06:57,490 So it will X in that case the positions x is greater than X limit and less then right limit. 83 00:06:57,500 --> 00:07:11,060 So here we have right limit and our via greater than the bottom less than the top so bottom limit and 84 00:07:11,060 --> 00:07:13,470 then less than the top limit. 85 00:07:13,830 --> 00:07:14,280 Let me go. 86 00:07:14,930 --> 00:07:18,880 I hope you understand this well because this is very easy and clear. 87 00:07:19,760 --> 00:07:23,360 And then just return inside. 88 00:07:23,740 --> 00:07:27,470 Maybe go after that one. 89 00:07:27,670 --> 00:07:30,230 We will define a move function. 90 00:07:30,230 --> 00:07:32,580 Define move. 91 00:07:32,690 --> 00:07:38,970 This will actually move a turtle or move under scored until is much better. 92 00:07:40,300 --> 00:07:42,320 That name has no effect. 93 00:07:42,610 --> 00:07:48,370 After that one we will check here whether it is inside the window or not. 94 00:07:48,520 --> 00:07:56,590 So if it is inside of the window then it will actually move over a turtle as it will take the turtle 95 00:07:56,590 --> 00:07:58,630 back to the window. 96 00:07:58,630 --> 00:08:00,610 So how will I do that one. 97 00:08:00,640 --> 00:08:11,260 First of all when it is inside the window so I will actually do the dot right and then I will pass just 98 00:08:11,260 --> 00:08:21,320 an angle at which it has to move and then I will make it run for what so forward say two hundred. 99 00:08:21,360 --> 00:08:25,750 You can take any distance and a task for you make this distance also. 100 00:08:26,460 --> 00:08:33,060 Now if I specified the angle by my own the two will always move with those particular angle but I don't 101 00:08:33,060 --> 00:08:33,660 need that one. 102 00:08:34,140 --> 00:08:37,440 So what will I do inside the if condition. 103 00:08:37,440 --> 00:08:43,620 I will define the angle as a random value between zero to one hundred and eighty because there are three 104 00:08:43,650 --> 00:08:47,390 possible angles so angle will be. 105 00:08:47,390 --> 00:08:51,550 If you remember creating the random values we have this an army R. 106 00:08:51,640 --> 00:08:58,430 Don't rend it and that will actually be in between zero to one hundred and eighty. 107 00:08:58,480 --> 00:09:06,610 So by this I will get a random value that random will be its move angle and then it will move forward. 108 00:09:07,070 --> 00:09:10,340 So similarly you have to make this forward distance is a random value. 109 00:09:11,450 --> 00:09:13,390 So I hope you will get that one. 110 00:09:13,580 --> 00:09:22,310 Just a distance variable and convert that also into random after that one if it is not inside the vendor. 111 00:09:22,540 --> 00:09:24,230 My mistake could get out of that one. 112 00:09:24,280 --> 00:09:33,850 So in that case just move backward with see a value 200 so that it will get making a lot no. 113 00:09:34,240 --> 00:09:42,780 After that when I need to call the functions so why it's true while it's inside that one so in that 114 00:09:42,780 --> 00:09:50,000 case just move title and positive balances maybe go whenever that is true. 115 00:09:50,010 --> 00:09:52,130 Just call it function. 116 00:09:52,360 --> 00:09:56,980 Remove that one and those fingers broke them. 117 00:09:57,210 --> 00:10:02,390 Maybe go so it's actually moving two hundred is tense and trend of values. 118 00:10:02,390 --> 00:10:06,360 I hope this one is very easy and also easy to understand. 119 00:10:08,580 --> 00:10:14,880 So you can also play with this one much wanting to play just look at it as if you want to make this 120 00:10:14,880 --> 00:10:25,620 one random just you need to pass here said best distance R B don't Rand int take between say from 50 121 00:10:25,620 --> 00:10:30,550 to 300 and parse this one here. 122 00:10:30,550 --> 00:10:40,670 List save and now when you land that 1 you will get this one moving with different distances 123 00:10:44,190 --> 00:10:49,590 so that's how you're gonna create this one but easily and also in that case make the backward distance 124 00:10:49,590 --> 00:10:53,520 to maximum 300 so that you do not get lost. 125 00:10:53,520 --> 00:10:58,730 So this is the code you will also get to check the errors whether you have any or not. 126 00:10:58,800 --> 00:11:00,690 And also this time is not required now. 127 00:11:02,280 --> 00:11:08,040 So this is all about this one and about the total graphics more you will understand the motion well 128 00:11:08,040 --> 00:11:12,710 we work on the projects we are required to move the figures with the keypad. 129 00:11:13,080 --> 00:11:14,190 So wait for that one. 130 00:11:14,400 --> 00:11:16,830 I hope you are excited with that. 131 00:11:16,980 --> 00:11:18,210 So thanks for watching. 132 00:11:18,210 --> 00:11:18,810 See you later.