1 00:00:05,750 --> 00:00:06,260 Yeah. 2 00:00:07,140 --> 00:00:12,390 So in this video with the a main logical flip program that will make the program track. 3 00:00:12,870 --> 00:00:14,840 So say this one stock gain 4 00:00:18,960 --> 00:00:19,580 maybe go. 5 00:00:20,280 --> 00:00:26,340 Now one thing most of you are already thinking about that how our keys would make the program work how 6 00:00:26,340 --> 00:00:29,470 we will intractable keyboard the this program. 7 00:00:29,490 --> 00:00:32,140 So for that fund we have a very simple matter. 8 00:00:32,250 --> 00:00:39,930 We use to denoting total load own key metal that is own pressing that particular key. 9 00:00:39,930 --> 00:00:45,670 What will happen and pass panties in these you required to pass two parameters. 10 00:00:45,690 --> 00:00:53,010 First one is the main function and if we do generally then first is the key that you are pressing like 11 00:00:53,160 --> 00:00:54,730 I'm going to press space. 12 00:00:54,900 --> 00:01:00,990 When my game begins I go in pressing this space you'll start the game so space 13 00:01:03,730 --> 00:01:06,220 and then what will happen on pressing Dedmon. 14 00:01:06,340 --> 00:01:10,450 So that will be going to be any commander any C function. 15 00:01:10,450 --> 00:01:13,600 So I'm going to call the function start game. 16 00:01:13,720 --> 00:01:17,990 So on pressing the space game we'll start. 17 00:01:18,010 --> 00:01:24,270 So this is how you can make your keyboard and your program to combine with each of them. 18 00:01:24,610 --> 00:01:33,350 And then just add data or policeman so that keyboard commands can be routed and in the last main loop. 19 00:01:33,430 --> 00:01:37,540 That is what we need to add part of a program. 20 00:01:37,680 --> 00:01:41,320 Now this is about space only rest commands. 21 00:01:41,330 --> 00:01:42,910 We will learn in the next video. 22 00:01:43,560 --> 00:01:45,850 Now let me move towards docking. 23 00:01:46,130 --> 00:01:53,660 So first of all in this tight game I'm taking a global variable that is say game started and the game 24 00:01:53,660 --> 00:01:57,690 is starting to space based few things happen. 25 00:01:57,690 --> 00:01:58,930 The first thing. 26 00:01:58,930 --> 00:02:02,690 If the game is already started and I'm pressing space right now. 27 00:02:03,430 --> 00:02:05,370 So that is something can also happen. 28 00:02:06,250 --> 00:02:12,170 So when the game is already started never done nothing. 29 00:02:13,910 --> 00:02:18,600 And after that one game started equal to draw. 30 00:02:19,880 --> 00:02:27,690 What's actually happening here is like when I just pressed this space first then I came to this when 31 00:02:27,750 --> 00:02:35,410 I have a variable game started and if it doesn't have anything then it will not go inside of this function. 32 00:02:35,630 --> 00:02:41,390 And if there is anything in that when like when it is already started and then it will return nothing 33 00:02:41,540 --> 00:02:48,170 it means that whenever I press space even after my program is running then there will be nothing happen 34 00:02:48,290 --> 00:02:49,120 with that space. 35 00:02:49,710 --> 00:02:52,100 Otherwise game will start again. 36 00:02:52,580 --> 00:03:00,700 And how game already started means is like if my game started is already drew then it will go inside 37 00:03:00,730 --> 00:03:07,590 that well then it may provide some adversarial programs to work in restarts. 38 00:03:07,630 --> 00:03:12,310 So this is a little come on that will only happen when the game is stagnant. 39 00:03:12,400 --> 00:03:14,690 In that case also it will return nothing. 40 00:03:14,830 --> 00:03:17,520 And after that this thing happen. 41 00:03:17,590 --> 00:03:20,430 Then game started equal to Drew. 42 00:03:20,830 --> 00:03:23,500 So from here of a game will start to work. 43 00:03:23,500 --> 00:03:25,820 This is for just checking that one. 44 00:03:26,350 --> 00:03:32,860 Now first of all when the game started begin Drew we will begin with this goal that is going to be 0 45 00:03:32,860 --> 00:03:38,210 initially so scored is initially zero and extra in the score. 46 00:03:38,210 --> 00:03:41,230 Total player. 47 00:03:41,320 --> 00:03:45,910 So what test on the desktop that is press space to start will begin. 48 00:03:45,910 --> 00:03:49,740 Zero and after that one we will work with the Caterpillar. 49 00:03:50,030 --> 00:03:54,130 So as soon as the program starts we a caterpillar. 50 00:03:55,040 --> 00:04:00,960 So Caterpillar underscores speed will do too. 51 00:04:01,220 --> 00:04:06,690 And Caterpillar land equal to say 3. 52 00:04:06,760 --> 00:04:15,330 We are digging if only three men here we will define Caterpillar not shape size. 53 00:04:15,510 --> 00:04:18,870 That is something that will make a look at the below a rectangle. 54 00:04:19,740 --> 00:04:21,060 And what we will do here. 55 00:04:21,110 --> 00:04:30,480 1 and then the caterpillar equation will enter that point and 1 in the end maybe love a deadline so 56 00:04:30,480 --> 00:04:33,720 we'll get to the mainland and one before and after. 57 00:04:33,720 --> 00:04:39,600 So although Caterpillar have three squares at that point after that one we need to show a caterpillar 58 00:04:40,200 --> 00:04:42,290 because it is hidden at this point. 59 00:04:42,720 --> 00:04:51,980 So short total if you remember we have hidden these turtles initially so we will show a turtle and then 60 00:04:51,980 --> 00:04:57,740 display scored with the current score which is actually zero right now. 61 00:04:57,740 --> 00:05:01,070 So this one will display zero. 62 00:05:01,760 --> 00:05:02,980 So here. 63 00:05:03,010 --> 00:05:04,920 Also past the current score. 64 00:05:05,030 --> 00:05:12,200 The barometer we are using here because now we have declared that none displayed this called Zero. 65 00:05:12,680 --> 00:05:15,880 And last thing placed the leaf. 66 00:05:15,950 --> 00:05:24,350 So this is the initial condition when you're trying to run this one we are getting an arrow a line equal 67 00:05:24,350 --> 00:05:34,700 to send 50 to line that we check that what that is so here we are missing a comma so save that one and 68 00:05:34,700 --> 00:05:35,300 run it again. 69 00:05:36,760 --> 00:05:38,140 There you go. 70 00:05:38,150 --> 00:05:43,540 We are getting this one press phase to start when I started this one I had my initial score to zero. 71 00:05:43,700 --> 00:05:49,750 The Caterpillar the this length the main landing beginning and then we have one end up and the Leaf 72 00:05:49,750 --> 00:05:51,110 randomly here. 73 00:05:51,340 --> 00:05:57,330 And when you start this one again then you have a leaf a different position that we have. 74 00:05:57,380 --> 00:06:02,250 But this thing but it will be a different collision. 75 00:06:02,350 --> 00:06:03,180 Now after that one. 76 00:06:03,520 --> 00:06:07,120 This is about the initial conditions that will begin with that one. 77 00:06:07,350 --> 00:06:24,810 Now while Drew while our game is started so until it remains draw my below will moving forward not action 78 00:06:27,870 --> 00:06:29,700 with its Caterpillar spin. 79 00:06:30,360 --> 00:06:34,170 So whatever this period has it will moving forward direction. 80 00:06:34,170 --> 00:06:38,730 And after that one we have two conditions. 81 00:06:38,770 --> 00:06:44,050 If this is hitting the leaf or not hitting the leaf then moving. 82 00:06:44,320 --> 00:06:48,130 And third one also manage to get hit in by vole. 83 00:06:48,370 --> 00:06:55,170 So first when the caterpillar say we are taking distance of the collision of these two. 84 00:06:55,270 --> 00:06:57,060 So distance with the leaf. 85 00:06:57,340 --> 00:07:01,070 So this is how you can compare the distance of two turtles. 86 00:07:01,180 --> 00:07:08,410 Main turtle it is the distance with the another one and then when this one is less than say 20 so 20 87 00:07:08,410 --> 00:07:11,460 is very small gap. 88 00:07:11,680 --> 00:07:18,460 What will happen in that case will first place live because as soon as they touch each other we must 89 00:07:18,460 --> 00:07:23,660 make sure that the original is disappear and a new one place at a different location. 90 00:07:23,860 --> 00:07:30,410 And after that one many in the Caterpillar eat that one Caterpillar land will increase by 1. 91 00:07:30,670 --> 00:07:41,800 So Caterpillar underscored land and that will be equal to Caterpillar land plus one and also the caterpillar 92 00:07:41,800 --> 00:07:43,390 speed. 93 00:07:43,600 --> 00:07:45,190 This one also increased by 1 94 00:07:48,320 --> 00:07:49,220 plus 1. 95 00:07:49,370 --> 00:07:54,980 And also when they land is increased now you again need to define the shape size of the caterpillar 96 00:07:55,460 --> 00:07:58,140 so that it will get updated with that one. 97 00:07:58,280 --> 00:08:01,070 They will have the same line here. 98 00:08:01,070 --> 00:08:06,440 After that one few more things you need to operate school maintain. 99 00:08:07,370 --> 00:08:17,850 So school will be school plus and and then this quality function display school with this new school 100 00:08:18,190 --> 00:08:23,750 that is going to be our current school and day we had this one. 101 00:08:24,070 --> 00:08:26,760 Now we do not require to operate anything else. 102 00:08:27,050 --> 00:08:28,660 And if 103 00:08:31,940 --> 00:08:33,100 outside the window. 104 00:08:33,890 --> 00:08:39,950 So if it this one hits the outside window or when this thing provides Drew. 105 00:08:40,700 --> 00:08:42,360 So what will happen in that case. 106 00:08:42,470 --> 00:08:48,690 Just call game over and provide a break clavicle. 107 00:08:48,950 --> 00:08:50,320 So this is very easy. 108 00:08:50,330 --> 00:08:58,310 If you focus a little on this one we have just checked first with a global variable like if the goal 109 00:08:58,310 --> 00:09:05,300 or this one is already started to do nothing then provide this one a you grew then we have initial conditions 110 00:09:05,300 --> 00:09:06,730 like school zero. 111 00:09:06,830 --> 00:09:10,650 We have cleared everything this text there like best best. 112 00:09:10,850 --> 00:09:17,810 Then we have the initial values speed and land of the caterpillar and the initial score and the leave 113 00:09:19,190 --> 00:09:21,590 after that one until this one remains true. 114 00:09:21,830 --> 00:09:25,300 Our Caterpillar remain moving oh keep moving. 115 00:09:25,400 --> 00:09:31,570 Then if their distance with the leaf is less than quality it means it has soil in the leaf then place 116 00:09:31,570 --> 00:09:35,000 Senator live and increase its length and speed. 117 00:09:35,190 --> 00:09:40,550 Also update this code and if it hits DiVall then the game is over. 118 00:09:42,260 --> 00:09:47,850 So this is about all the functions and main objects but there's one thing left here. 119 00:09:47,860 --> 00:09:52,670 Now if you run your code you will get your game there hit return. 120 00:09:52,800 --> 00:10:01,370 So this space you will get this one moving but you cannot control Dettmer and your score it is essentially 121 00:10:01,370 --> 00:10:01,900 here. 122 00:10:02,330 --> 00:10:04,240 So how to do that one. 123 00:10:05,060 --> 00:10:08,570 So that's something we are going to learn in the next video. 124 00:10:08,690 --> 00:10:09,920 So thanks for watching. 125 00:10:09,920 --> 00:10:10,850 Soon the next video.