1 00:00:00,429 --> 00:00:04,167 In this video, I'm going to complete the first practice before you, 2 00:00:04,168 --> 00:00:08,575 just so you see how the practice system works in the course. 3 00:00:08,767 --> 00:00:12,414 First, we want to open Learn to Code with Godot Practices, 4 00:00:12,415 --> 00:00:14,100 the one with the purple icon. 5 00:00:14,143 --> 00:00:15,975 So I'll double double click it. 6 00:00:17,208 --> 00:00:21,558 When you first open it, you're going to land on the 3D viewport. 7 00:00:21,750 --> 00:00:24,571 This will change afterwards once you do the first practice. 8 00:00:24,572 --> 00:00:27,629 But this is how it goes by default. 9 00:00:28,043 --> 00:00:33,243 Unlike a normal Godot project, on the right, you have a new doc, 10 00:00:33,244 --> 00:00:34,614 GDQuest Practices. 11 00:00:34,775 --> 00:00:39,417 This one is where you'll open and manage the practices. 12 00:00:39,714 --> 00:00:44,257 The first one is in the first chapter: To Space and Beyond. 13 00:00:44,357 --> 00:00:48,700 So you can click that to unfold it and see the corresponding practices. 14 00:00:49,375 --> 00:00:53,183 In the lesson, it tells us to do making the ship move, 15 00:00:53,184 --> 00:00:54,442 so I'm going to click it. 16 00:00:54,642 --> 00:00:57,408 Instantly it opens a scene in Godot. 17 00:00:57,409 --> 00:00:59,642 It expands the corresponding directory 18 00:00:59,643 --> 00:01:00,950 in the bottom left 19 00:01:01,125 --> 00:01:04,592 and it gives us some information about the practice, the description, 20 00:01:04,593 --> 00:01:06,375 the techniques you'll practice, 21 00:01:06,608 --> 00:01:08,925 a list of tasks that we have to complete, 22 00:01:08,926 --> 00:01:10,871 and optional hints. 23 00:01:11,440 --> 00:01:13,243 Now, typically to complete a practice, 24 00:01:13,244 --> 00:01:16,786 you need to change the scene or the scripts in there. 25 00:01:17,600 --> 00:01:21,375 And then you run the scene by pressing F6 26 00:01:21,530 --> 00:01:24,343 and the practice system will check your code, 27 00:01:24,344 --> 00:01:27,386 just like the Learn GDScript app you did before. 28 00:01:28,750 --> 00:01:30,913 For any check that you don't pass, 29 00:01:30,914 --> 00:01:32,900 you're going to get a message on the right, 30 00:01:32,901 --> 00:01:35,742 an error message, that will give you some hints 31 00:01:35,743 --> 00:01:39,886 or information that may help you complete the practice, 32 00:01:39,887 --> 00:01:41,643 at least that's the goal. 33 00:01:42,683 --> 00:01:44,183 Once you're done testing like that, 34 00:01:44,184 --> 00:01:48,450 you can press F8 to close the running scene. 35 00:01:49,333 --> 00:01:50,856 We have the description on the right 36 00:01:50,857 --> 00:01:55,086 using a fixed velocity, we need to make the ship move by itself. 37 00:01:55,087 --> 00:01:57,543 It's the same we did in the lesson. 38 00:01:57,544 --> 00:02:02,182 The idea is that you reproduce it in this very first practice, 39 00:02:02,183 --> 00:02:07,158 just as some kind of muscle memory training, 40 00:02:07,159 --> 00:02:08,257 if you want. 41 00:02:08,258 --> 00:02:10,414 It's taking some small steps. 42 00:02:10,415 --> 00:02:12,533 As you move forward through the course, 43 00:02:12,534 --> 00:02:14,908 the practices will become more and more unique 44 00:02:14,909 --> 00:02:17,286 and different from the lessons. 45 00:02:17,400 --> 00:02:21,043 But for the first ones, we keep it very simple. 46 00:02:21,867 --> 00:02:23,032 We have the tasks, 47 00:02:23,033 --> 00:02:26,017 we need to make sure the ship moves every frame 48 00:02:26,018 --> 00:02:27,058 at a fixed speed. 49 00:02:27,292 --> 00:02:30,616 We have to take the Delta parameter into account 50 00:02:30,617 --> 00:02:33,077 and use the variable name velocity, 51 00:02:33,078 --> 00:02:34,786 which we defined for you. 52 00:02:35,000 --> 00:02:37,900 I'm going to click the script icon next to the sprite 53 00:02:37,901 --> 00:02:42,014 to open the script and there I have a bit of code. 54 00:02:42,130 --> 00:02:45,100 I have a velocity variable that's been predefined. 55 00:02:45,101 --> 00:02:48,058 And you can see we've defined the process function for you 56 00:02:48,059 --> 00:02:49,699 and we have the position. 57 00:02:49,700 --> 00:02:51,133 Now, two things. 58 00:02:51,258 --> 00:02:58,042 The velocity is set to Vector2.ZERO, this is equivalent to Vector2(0,0). 59 00:02:58,043 --> 00:03:01,258 So the ship will not move even if we use that value. 60 00:03:01,259 --> 00:03:02,714 So we need to change it. 61 00:03:02,815 --> 00:03:05,600 Then we need to change the ship's position. 62 00:03:06,400 --> 00:03:07,840 First things first, 63 00:03:08,040 --> 00:03:11,800 I'm going to change the Vector2 value for my velocity 64 00:03:11,801 --> 00:03:13,200 and make the ship move. 65 00:03:13,201 --> 00:03:16,383 Any value that's non-zero should work. 66 00:03:16,858 --> 00:03:19,871 Then every frame in the process function, 67 00:03:19,943 --> 00:03:21,775 I'm going to add to my position. 68 00:03:21,776 --> 00:03:23,533 I'm going to add velocity. 69 00:03:23,534 --> 00:03:26,475 I can run the scene with F6 to see that, 70 00:03:26,476 --> 00:03:28,500 well, the first check is not passing 71 00:03:28,514 --> 00:03:32,692 or I'm not taking Delta into account, but the other two are. 72 00:03:33,043 --> 00:03:35,149 And so we get a message that tells us that 73 00:03:35,150 --> 00:03:37,782 we're not multiplying the velocity by Delta 74 00:03:37,783 --> 00:03:41,275 and that's what we need to do to make the movement time dependent. 75 00:03:42,692 --> 00:03:46,400 We're going to multiply the velocity by Delta, 76 00:03:46,500 --> 00:03:47,590 run again, 77 00:03:48,392 --> 00:03:51,185 and now we pass the three checks. 78 00:03:51,186 --> 00:03:52,986 This completes the practice. 79 00:03:53,115 --> 00:03:55,671 And so we can choose to stay and play the scene 80 00:03:55,672 --> 00:03:58,570 or we can quit and go back to the editor. 81 00:03:58,571 --> 00:04:02,042 There, you'll see the progress bar increased 82 00:04:02,043 --> 00:04:05,886 and we see a green check mark next to the practice. 83 00:04:06,157 --> 00:04:07,143 This gets saved. 84 00:04:07,144 --> 00:04:12,429 So even if you update to a newer version of the course, this will be kept. 85 00:04:12,529 --> 00:04:16,843 Because in the future, we want to maybe add a couple more practices. 86 00:04:17,150 --> 00:04:19,924 We might be changing some existing practices, 87 00:04:19,925 --> 00:04:21,857 but your progress will not be lost. 88 00:04:21,943 --> 00:04:23,486 Just one note about that, 89 00:04:23,487 --> 00:04:26,543 this progress is stored on your computer. 90 00:04:26,692 --> 00:04:28,400 So if you format your computer, 91 00:04:28,457 --> 00:04:32,433 you clear the hard drive or you work from another computer, 92 00:04:32,434 --> 00:04:35,650 it will not carry on. 93 00:04:36,229 --> 00:04:40,775 You can find your saved file by going to Project, 94 00:04:41,149 --> 00:04:43,357 Open Project Data Folder. 95 00:04:43,544 --> 00:04:46,486 This is a folder Godot creates for you. 96 00:04:46,487 --> 00:04:50,415 This is where you put the user saves, those kinds of things. 97 00:04:50,416 --> 00:04:55,183 And this is this file progress.tres, text resource, 98 00:04:56,133 --> 00:04:58,129 that is used to track your progress. 99 00:04:58,171 --> 00:05:00,928 So if you want to go on a laptop 100 00:05:00,929 --> 00:05:06,058 or to continue on another computer, 101 00:05:06,059 --> 00:05:08,883 you'll want to copy this file over. 102 00:05:09,533 --> 00:05:14,000 With that, I'll let you do the first practice yourself. 103 00:05:14,001 --> 00:05:15,849 Again, it shouldn't be too hard, 104 00:05:15,850 --> 00:05:21,214 but then you'll be moving on to the other practices that you'll tackle on your own. 105 00:05:21,215 --> 00:05:22,486 Best of luck with that.