1 00:00:00,271 --> 00:00:05,071 The last thing I want us to do is add some code to our project. 2 00:00:05,543 --> 00:00:10,120 If you go near a chest, it will open, but nothing comes out of it. 3 00:00:10,329 --> 00:00:14,520 It's not spawning an item for the player to loot. 4 00:00:14,757 --> 00:00:16,214 And we want to remedy that. 5 00:00:16,879 --> 00:00:21,600 To do so we're going to search for the chest in our project. 6 00:00:22,129 --> 00:00:26,920 And we have a Chest.tscn in Scene that we could open by double-clicking. 7 00:00:27,329 --> 00:00:30,480 And this has a script attached to it. 8 00:00:30,714 --> 00:00:36,520 The icon there tells you that you have some code attached to a node, 9 00:00:36,814 --> 00:00:40,600 so you can click the icon to open the corresponding script. 10 00:00:40,729 --> 00:00:42,070 Don't worry about the code. 11 00:00:42,071 --> 00:00:45,360 You'll learn about what everything means in due time. 12 00:00:45,629 --> 00:00:48,488 For now, we're just going to write a line of code 13 00:00:48,489 --> 00:00:50,986 and see how it changes our game behavior. 14 00:00:51,271 --> 00:00:54,080 You have these lines, func loot. 15 00:00:54,371 --> 00:00:57,500 This is a function named loot. 16 00:00:57,643 --> 00:01:02,480 It's code the game executes when you pass in front of the chest. 17 00:01:02,971 --> 00:01:06,543 And in that function, after the second line, 18 00:01:06,729 --> 00:01:08,429 _animation_player.play("loot"), 19 00:01:08,629 --> 00:01:11,800 we need to create a pickup for the player. 20 00:01:12,157 --> 00:01:16,071 So you're going to place your cursor at the end of the line by clicking 21 00:01:16,357 --> 00:01:19,656 and then press enter to create a new line 22 00:01:19,657 --> 00:01:22,470 with this leading tab here. 23 00:01:22,471 --> 00:01:23,760 It's very important. 24 00:01:24,471 --> 00:01:28,771 You then want to call the function called create pickup. 25 00:01:29,300 --> 00:01:34,185 To do so, you type its name, starting with underscore create, 26 00:01:34,186 --> 00:01:37,557 and you will get this suggestion from the engine, 27 00:01:37,800 --> 00:01:40,200 which you can accept by pressing enter, 28 00:01:40,414 --> 00:01:43,871 and it will automatically complete the line for you. 29 00:01:44,629 --> 00:01:49,857 With that, you can press F5 to play the game and walk your character. 30 00:01:49,971 --> 00:01:54,210 And as you pass in front of the chest, it will create a random pickup. 31 00:01:55,043 --> 00:01:58,400 With that, you saw how to assemble a game. 32 00:01:58,401 --> 00:02:00,756 There are a couple things that we could improve. 33 00:02:00,757 --> 00:02:05,400 For example, in our game right now, we are missing some invisible walls. 34 00:02:05,543 --> 00:02:09,532 If you want to add them, you select the invisible walls 35 00:02:09,533 --> 00:02:12,057 in your main scene tab there, 36 00:02:12,371 --> 00:02:16,712 and you click and drag on the cells where you want the walls, 37 00:02:16,713 --> 00:02:19,000 and you right-click and drag to remove them. 38 00:02:19,343 --> 00:02:22,505 Note that some walls exist in the room scenes, 39 00:02:22,506 --> 00:02:25,071 which is why you cannot erase them this way. 40 00:02:25,357 --> 00:02:30,214 You can just use this InvisibleWalls node 41 00:02:30,757 --> 00:02:35,528 to create new walls that don't exist in the other scenes like so 42 00:02:35,529 --> 00:02:39,829 and that will prevent the player from walking in the sky. 43 00:02:40,129 --> 00:02:44,271 Now, this is where this little introduction project ends. 44 00:02:44,443 --> 00:02:46,856 You will learn to create this game, 45 00:02:46,857 --> 00:02:50,956 however, to do so, we need to first take a step back, 46 00:02:50,957 --> 00:02:55,732 learn the basics of programming and create much smaller projects 47 00:02:55,733 --> 00:02:58,957 and create all those parts that you saw here, 48 00:02:58,958 --> 00:03:01,142 like the player, the weapon, the chest, 49 00:03:01,143 --> 00:03:04,680 we'll learn to code those as separate chunks. 50 00:03:04,971 --> 00:03:08,586 And you will then get to put your twist on them 51 00:03:08,587 --> 00:03:11,900 and assemble them into a game that you'll make, 52 00:03:12,114 --> 00:03:15,160 I hope, your own by the end of the course. 53 00:03:15,671 --> 00:03:19,799 With that, in the next part, we'll talk about the learn GDScript app, 54 00:03:19,800 --> 00:03:22,657 a free and open-source application that will teach you 55 00:03:22,658 --> 00:03:27,114 the basics of scripting with the GDScript programming language. 56 00:03:27,229 --> 00:03:28,392 See you there.