summaryrefslogtreecommitdiff
path: root/live/blog/g/godot_project_structure.html
blob: 0a2e8d0951800968207efd8c1fb20e32bc6817f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
<!DOCTYPE html>
<html class="theme-dark" lang="en
"
  prefix="og: https://ogp.me/ns#">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" href="https://static.luevano.xyz/images/icons/favicon.ico">
<title>General Godot project structure -- Luévano's Blog</title>
  <meta name="description" content="Details on the project structure I'm using for Godot, based on preference and some research I did."/>
<link rel="alternate" type="application/rss+xml" href="https://blog.luevano.xyz/rss.xml" title="Luévano's Blog RSS">
    <!-- general style -->
    <link rel="stylesheet" type="text/css" href="https://static.luevano.xyz/css/style.css">
    <link rel="stylesheet" type="text/css" href="https://static.luevano.xyz/fork-awesome/css/fork-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="https://static.luevano.xyz/font-awesome/css/all.min.css">
    <!-- theme related -->
    <script type="text/javascript" src="https://static.luevano.xyz/scripts/theme.js"></script>
    <link id="theme-css" rel="stylesheet" type="text/css" href="https://static.luevano.xyz/css/theme.css">
    <!-- misc functions-->
    <script type="text/javascript" src="https://static.luevano.xyz/scripts/return_top.js"></script>
    <!-- extra -->




    <!-- og meta -->
  <meta property="og:title" content="General Godot project structure -- Luévano's Blog"/>
  <meta property="og:type" content="article"/>
  <meta property="og:url" content="https://blog.luevano.xyz/g/godot_project_structure.md"/>
  <meta property="og:image" content="https://static.luevano.xyz/images/b/default.png"/>
  <meta property="og:description" content="Details on the project structure I'm using for Godot, based on preference and some research I did."/>
  <meta property="og:locale" content="en"/>
  <meta property="og:site_name" content="Luévano's Blog"/>
  </head>

  <body>
    <header>
<nav>
  <ul>
    <li>
      <a href="https://luevano.xyz/"><i class="fas fa-home" alt="Home"></i><span>Home</span></a>
    </li>

    <li>
      <a href="https://blog.luevano.xyz/"><i class="fas fa-book-open" alt="Blog"></i><span>Blog</span></a>
    </li>

    <li>
      <a href="https://art.luevano.xyz/"><i class="fas fa-paint-brush" alt="Art"></i><span>Art</span></a>
    </li>

    <li><i class="fab fa-git" alt="Git"></i><span>Git</span>
      <ul>
        <li><a href="https://git.luevano.xyz/" target="_blank"><i class="fab fa-git-alt" alt="Git-alt"></i></a></li>

        <li><a href="https://github.com/luevano" target="_blank"><i class="fab fa-github" alt="Github"></i></a></li>

        <li><a href="https://gitlab.com/dluevano" target="_blank"><i class="fab fa-gitlab" alt="Gitlab"></i></a></li>
      </ul>
    </li>

    <li><i class="fas fa-box-open" alt="Stuff"></i><span>Stuff</span>
      <ul>
        <li><a href="https://gb.luevano.xyz/"><i class="fas fa-gamepad" alt="Gameboy"></i><span>Gameboy</span></a></li>
      </ul>
    </li>
  </ul>
</nav>

<button class="theme-switcher" onclick="toggleTheme()"><i class="fas fa-moon"></i><i class="fas fa-sun"></i></button>

    </header>

    <main>
      <div class="return-top">
        <button class="return-top" onclick="returnTop()" id="returnTopButton">
        <i class="fas fa-arrow-up" alt="Return to top"></i>
        </button>
      </div>
  <h1>General Godot project structure</h1>

  <p>One of my first issues when starting a project is how to structure everything. So I had to spend some time researching best practices and go with what I like the most and after trying some of them I wanted to write down somewhere what I&rsquo;m sticking with.</p>
<p>The first place to look for is, of course, the official <em>Godot</em> documentation on <a href="https://docs.godotengine.org/en/stable/tutorials/best_practices/project_organization.html">Project organization</a>; along with project structure discussion, also comes with best practices for code style and what-not. I don&rsquo;t like this project/directory structure that much, just because it tells you to bundle everything under the same directory but it&rsquo;s a really good starting point, for example it tells you to use:</p>
<ul>
<li>/models/town/house/<ul>
<li>house.dae</li>
<li>window.png</li>
<li>door.png</li>
</ul>
</li>
</ul>
<p>Where I would prefer to have more modularity, for example:</p>
<ul>
<li>/levels/structures/town/house (or /levels/town/structures/house)<ul>
<li>window/<ul>
<li>window.x</li>
<li>window.y</li>
<li>window.z</li>
</ul>
</li>
<li>door/<ul>
<li>&hellip;</li>
</ul>
</li>
<li>house.x</li>
<li>house.y</li>
<li>house.z</li>
</ul>
</li>
</ul>
<p>It might look like it&rsquo;s more work, but I prefer it like this. I wish <a href="https://www.braindead.bzh/entry/creating-a-game-with-godot-engine-ep-2-project-organization">this site</a> was still available, as I got most of my ideas from there and was a pretty good resource, but apparently the owner is not maintaining his site anymore; but there is <a href="https://www.reddit.com/r/godot/comments/7786ee/comment/dojuzuf/?utm_source=share&amp;utm_medium=web2x&amp;context=3">this excelent comment on reddit</a> which shows a project/directory structure more in line with what I&rsquo;m currently using (and similr to the site that is down that I liked). I ended up with:</p>
<ul>
<li>/.git</li>
<li>/assets (raw assets/editable assets/asset packs)</li>
<li>/releases (executables ready to publish)</li>
<li>/src (the actual godot project)<ul>
<li>.godot/</li>
<li>actors/ (or entities)<ul>
<li>player/<ul>
<li>sprites/</li>
<li>player.x</li>
<li>&hellip;</li>
</ul>
</li>
<li>enemy/ (this could be a dir with subdirectories for each type of enemy for example&hellip;)<ul>
<li>sprites/</li>
<li>enemy.x</li>
<li>&hellip;</li>
</ul>
</li>
<li>actor.x</li>
<li>&hellip;</li>
</ul>
</li>
<li>levels/ (or scenes)<ul>
<li>common/<ul>
<li>sprites/</li>
<li>&hellip;</li>
</ul>
</li>
<li>main/<ul>
<li>&hellip;</li>
</ul>
</li>
<li>overworld/<ul>
<li>&hellip;</li>
</ul>
</li>
<li>dugeon/<ul>
<li>&hellip;</li>
</ul>
</li>
<li>Game.tscn (I&rsquo;m considering the &ldquo;Game&rdquo; as a level/scene)</li>
<li>game.gd</li>
</ul>
</li>
<li>objects/<ul>
<li>box/<ul>
<li>&hellip;</li>
</ul>
</li>
<li>&hellip;</li>
</ul>
</li>
<li>screens/<ul>
<li>main_menu/<ul>
<li>&hellip;</li>
</ul>
</li>
<li>&hellip;</li>
</ul>
</li>
<li>globals/ (singletons/autoloads)</li>
<li>ui/<ul>
<li>menus/<ul>
<li>&hellip;</li>
</ul>
</li>
<li>&hellip;</li>
</ul>
</li>
<li>sfx/<ul>
<li>&hellip;</li>
</ul>
</li>
<li>vfx/<ul>
<li>&hellip;</li>
</ul>
</li>
<li>etc/<ul>
<li>&hellip;</li>
</ul>
</li>
<li>Main.tscn (the entry point of the game)</li>
<li>main.gd</li>
<li>icon.png (could also be on a separate &ldquo;icons&rdquo; directory)</li>
<li>project.godot</li>
<li>&hellip;</li>
</ul>
</li>
<li>\&lt;any other repository related files&gt;</li>
</ul>
<p>And so on, I hope the idea is clear. I&rsquo;ll probably change my mind on the long run, but for now this has been working fine.</p>

  <div class="page-nav">
    <span class="next">
      <a href="https://blog.luevano.xyz/g/flappybird_godot_devlog_1.html" alt="Next">
        <i class="fas fa-arrow-left" alt="Arrow left"></i>
        <span>Next</span>
      </a>
    </span>

    <span class="index">
      <a href="https://blog.luevano.xyz" alt="Index">
        <i class="fas fa-home" alt="Home"></i>
        <span>Index</span>
      </a>
    </span>

    <span class="previous">
      <a href="https://blog.luevano.xyz/g/starting_gamedev_blogging.html" alt="Previous">
        <i class="fas fa-arrow-right" alt="Arrow right"></i>
        <span>Previous</span>
      </a>
    </span>
</div>


  <hr>
  <div class="article-info">
    <p>By David Luévano</p>
    <p>Created: Sun, May 22, 2022 @ 01:16 UTC</p>
      <p>Modified: Fri, May 05, 2023 @ 08:37 UTC</p>
    <div class="article-tags">
  <p>Tags:
<a href="https://blog.luevano.xyz/tag/@english.html">english</a>, <a href="https://blog.luevano.xyz/tag/@gamedev.html">gamedev</a>, <a href="https://blog.luevano.xyz/tag/@godot.html">godot</a>, <a href="https://blog.luevano.xyz/tag/@short.html">short</a>  </p>
</div>

  </div>
    </main>

    <footer>
<span>
  <i class="fas fa-address-card" alt="Contact"></i>
  <a href="https://blog.luevano.xyz/contact.html">Contact</a>
</span>

<span>
  <i class="fas fa-donate" alt="Donate"></i>
  <a href="https://blog.luevano.xyz/donate.html">Donate</a>
</span>

<span>
  <i class="fas fa-rss" alt="RSS"></i>
  <a target="_blank" href="https://blog.luevano.xyz/rss.xml">RSS</a>
</span>

<br>
<span class="created-with">
  <i class="fas fa-hammer" alt="Hammer"></i>
  Created with <a href="https://github.com/luevano/pyssg">pyssg</a>
</span>

<br>
<span class="copyright">
  Copyright <i class="far fa-copyright" alt="Copyright"></i> 2023 David Luévano Alvarado
</span>

    </footer>
  </body>
</html>