1 00:00:00,000 --> 00:00:02,171 In this video, we're going to discuss 2 00:00:02,186 --> 00:00:06,013 how we organized the final game project files 3 00:00:06,014 --> 00:00:09,914 and how you want to organize your own games in general. 4 00:00:10,101 --> 00:00:13,657 A game like this is going to take lots of files. 5 00:00:13,658 --> 00:00:19,314 You're going to need need to browse the game's code and change it many times. 6 00:00:19,414 --> 00:00:23,713 You want to split it into folders and files that make sense, 7 00:00:23,714 --> 00:00:27,043 so that after six months of development, after one year, 8 00:00:27,044 --> 00:00:30,400 you can still find the scripts that you need to fix. 9 00:00:30,443 --> 00:00:33,843 You can find where is the code for pickups for the character, 10 00:00:33,844 --> 00:00:35,343 et cetera, easily 11 00:00:35,344 --> 00:00:37,400 and that everything makes sense. 12 00:00:37,401 --> 00:00:40,299 The way we approach it at GDQuest, 13 00:00:40,300 --> 00:00:47,128 is we typically have one directory for each scenes. 14 00:00:47,129 --> 00:00:50,857 Everything that has to do with the interface is in the interface folder, 15 00:00:50,858 --> 00:00:55,600 or for a given game system or standalone component. 16 00:00:55,601 --> 00:00:58,514 For example, everything that's player-controlled 17 00:00:58,515 --> 00:01:02,486 goes into this robot directory, that's the player's robot. 18 00:01:02,487 --> 00:01:06,328 Why? Because this one can work on its own. 19 00:01:06,329 --> 00:01:09,980 We can run it into a scene with the spells, with the movement. 20 00:01:10,010 --> 00:01:14,113 We don't need a level to test that everything is working. 21 00:01:14,314 --> 00:01:15,600 When working on the robot, 22 00:01:15,671 --> 00:01:18,900 we put all the files in there, which we can easily drag and drop 23 00:01:18,901 --> 00:01:20,786 into the inspector, and so on. 24 00:01:21,986 --> 00:01:23,014 That's the robot. 25 00:01:23,015 --> 00:01:27,086 There are cases that are more complex, like the mobs in this game. 26 00:01:27,087 --> 00:01:30,785 The player has enemies that are those mobs. 27 00:01:30,786 --> 00:01:34,543 And in there, you will see multiple subdirectories. 28 00:01:34,544 --> 00:01:38,329 In this case, each of the mob inherits from a base scene 29 00:01:38,330 --> 00:01:40,113 and script, Mob.gd. 30 00:01:40,114 --> 00:01:43,800 In those cases, we will typically put the base class, 31 00:01:43,829 --> 00:01:49,057 the mob class here, into the main directory mobs. 32 00:01:49,341 --> 00:01:51,854 And for every entity that inherits from it, 33 00:01:51,910 --> 00:01:54,471 we make as dedicated directory. 34 00:01:55,230 --> 00:01:57,215 For example, the sword here. 35 00:01:57,571 --> 00:02:02,229 The reason we do that is that typically, mobs will tend to grow. 36 00:02:02,230 --> 00:02:05,670 At first, you will just have one or two sprites probably, 37 00:02:05,671 --> 00:02:08,285 then you will start to add visual effects, 38 00:02:08,286 --> 00:02:10,686 you will start to add unique sounds to each of the mobs, 39 00:02:10,701 --> 00:02:11,914 those kinds of things. 40 00:02:11,915 --> 00:02:15,706 And so the number of files in the directory may grow. 41 00:02:15,760 --> 00:02:19,057 We keep one directory for each of the mob. 42 00:02:19,058 --> 00:02:21,071 The shield, the dummy, the bomb, etc. 43 00:02:21,072 --> 00:02:23,557 This makes them fairly easy to browse. 44 00:02:24,090 --> 00:02:28,014 You may notice that you have a couple more files in this directory. 45 00:02:28,250 --> 00:02:31,614 This is everything that might be shared by various monsters. 46 00:02:31,702 --> 00:02:35,957 Whenever something's shared, we move it up a directory. 47 00:02:36,101 --> 00:02:40,786 In this case, it's the damage sound, the death sound for monsters, 48 00:02:40,815 --> 00:02:45,014 and this cannon which is a gun that can shoot the bullets 49 00:02:45,015 --> 00:02:47,357 that we have in a separate folder. 50 00:02:47,657 --> 00:02:48,837 In this game, 51 00:02:49,037 --> 00:02:53,171 both the player can shoot projectiles using spells, 52 00:02:53,172 --> 00:02:58,060 and the mobs, thanks to this cannon scene that we have here. 53 00:02:58,090 --> 00:03:02,971 We decided to have the bullets, the projectiles, as a separate directory. 54 00:03:02,972 --> 00:03:05,986 We decided that the mobs, the player could use them, 55 00:03:05,987 --> 00:03:08,800 but also you could use them as part of a trap. 56 00:03:08,801 --> 00:03:13,029 For example, if you want to walk on a pressure plate that triggers bullets. 57 00:03:13,615 --> 00:03:16,871 Next, we have the pickups that the player can grab. 58 00:03:17,343 --> 00:03:21,300 Those allow you to get a spell, 59 00:03:21,301 --> 00:03:24,243 but you can also regain health, and you could use them 60 00:03:24,244 --> 00:03:27,329 for temporary boost for the player or something like that. 61 00:03:27,357 --> 00:03:32,800 It's a mechanic of its own, which is why it has its own folder. 62 00:03:33,640 --> 00:03:35,535 The props are not too important there 63 00:03:35,735 --> 00:03:39,786 all the small things that can be shared by the levels. 64 00:03:39,829 --> 00:03:42,371 You have the shadow that both the monsters and the player use, 65 00:03:42,372 --> 00:03:43,957 the sky for the background. 66 00:03:44,370 --> 00:03:48,660 It's everything that didn't fit in another directory. 67 00:03:48,690 --> 00:03:51,114 One thing we do sometimes in our projects, 68 00:03:51,115 --> 00:03:54,257 instead of calling this props, we'll call this common. 69 00:03:54,529 --> 00:03:57,614 And those are all the files that we intend to reuse 70 00:03:57,615 --> 00:03:59,157 about anywhere in the game. 71 00:03:59,158 --> 00:04:03,929 This could be generic sounds, generic sprites or reusable scripts. 72 00:04:05,357 --> 00:04:09,043 There's one last folder that's very important in this project, 73 00:04:09,044 --> 00:04:10,971 it's the room's directory. 74 00:04:10,972 --> 00:04:15,513 This one has all the procedural levels' rooms, 75 00:04:15,514 --> 00:04:16,729 as you can see. 76 00:04:17,914 --> 00:04:20,471 Each of them extends from base room. 77 00:04:20,872 --> 00:04:24,685 Because each of the room is just a scene and it's self-contained, 78 00:04:24,757 --> 00:04:28,443 we decided not to make extra subdirectories for them. 79 00:04:28,971 --> 00:04:30,915 They are all next to the base room, 80 00:04:30,916 --> 00:04:35,771 and we can use all of these in our procedural level generator. 81 00:04:35,973 --> 00:04:39,871 We also have the test room in there that we use only to test the game 82 00:04:39,872 --> 00:04:42,457 and for development, there we just put pickups, 83 00:04:42,514 --> 00:04:44,557 or put spells, enemies, 84 00:04:44,771 --> 00:04:47,714 just to test that the mechanics are working. 85 00:04:48,061 --> 00:04:53,157 You can see how we have a fairly flat folder structure for this project. 86 00:04:54,130 --> 00:04:57,843 Meaning that you have quite a few folders at the root of the project, 87 00:04:57,844 --> 00:05:00,300 and you don't have too many subfolders. 88 00:05:00,301 --> 00:05:04,556 This is something we recommend, it makes it easy to open the folders 89 00:05:04,557 --> 00:05:07,057 and get a Godot sense for the code structure. 90 00:05:07,058 --> 00:05:11,500 This is something we recommend over nesting folders too much. 91 00:05:11,501 --> 00:05:13,086 That would be having the robot, 92 00:05:13,087 --> 00:05:16,957 and then inside the bullets and the spells, nested into one another. 93 00:05:16,986 --> 00:05:21,543 Because then it makes it a bit harder to browse your game files. 94 00:05:22,360 --> 00:05:24,429 There are two more important things here. 95 00:05:24,557 --> 00:05:26,114 First, we have folders 96 00:05:26,115 --> 00:05:29,128 that directly represent our game structure. 97 00:05:29,300 --> 00:05:32,143 We have bullets in the game, so we have a bullets' folder. 98 00:05:32,144 --> 00:05:34,800 We have mobs in the game, so we have a mobs' folder. 99 00:05:34,801 --> 00:05:37,986 And the related code is contained in there. 100 00:05:37,987 --> 00:05:41,357 You have people who will use and recommend always the same structure. 101 00:05:41,358 --> 00:05:48,231 Say they will have an interface folder, a level entities' folder, a player folder, 102 00:05:48,232 --> 00:05:51,313 and those kinds of things, and they will use it for every game. 103 00:05:51,314 --> 00:05:54,985 And I don't recommend that because it's not as clear 104 00:05:54,986 --> 00:05:56,157 what the game is about 105 00:05:56,158 --> 00:05:59,171 and where you will find all the files as this. 106 00:05:59,172 --> 00:06:02,082 Bullets, user interface, mobs, 107 00:06:02,083 --> 00:06:05,200 robot could be player or character, or something like that. 108 00:06:05,201 --> 00:06:07,029 But pickups, room, spells, 109 00:06:07,030 --> 00:06:10,400 it's pretty explicit where you will find the code, 110 00:06:10,529 --> 00:06:12,171 the sprites, and the scenes, 111 00:06:12,257 --> 00:06:14,200 for each of the game mechanic.