version_control.rst 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. Version Control & Project Organization
  2. ======================================
  3. Introduction
  4. ------------
  5. This tutorial is aimed to propose a simple workflow on how to organize
  6. projects. Since Godot allows the programmer to use the file-system as he
  7. or she pleases, figuring out a way to organize the projects when
  8. starting to use the engine can be a little challenging. Because of this,
  9. a simple workflow will be described, which can be used or not, but
  10. should work as a starting point.
  11. Additionally, using version control can be challenging so this
  12. proposition will include that too.
  13. Organization
  14. ------------
  15. Other game engines often work by having an asset database, were you can
  16. browse images, models, sounds, etc. Godot is more scene-based in nature
  17. so most of the time the assets are bundled inside the scenes or just
  18. exist as files but are referenced from scenes.
  19. Importing & Game Folder
  20. -----------------------
  21. It is very often necessary to use asset importing in Godot. As the
  22. source assets for importing are also recognized as resources by the
  23. engine, this can become a problem if both are inside the project folder,
  24. because at the time of export the exporter will recognize them and
  25. export both.
  26. To solve this, it is a good practice to have your game folder inside
  27. another folder (the actual project folder). This allows to have the game
  28. assets separated from the source assets, and also allows to use version
  29. control (such as svn or git) for both. Here is an example:
  30. ::
  31. myproject/art/models/house.max
  32. myproject/art/models/sometexture.png
  33. myproject/sound/door_open.wav
  34. myproject/sound/door_close.wav
  35. myproject/translations/sheet.csv
  36. Then also, the game itself is, in this case, inside a game/ folder:
  37. ::
  38. myproject/game/engine.cfg
  39. myproject/game/scenes/house/house.scn
  40. myproject/game/scenes/house/sometexture.tex
  41. myproject/game/sound/door_open.smp
  42. myproject/game/sound/door_close.smp
  43. myproject/game/translations/sheet.en.xl
  44. myproject/game/translations/sheet.es.xl
  45. Following this layout, many things can be done:
  46. - The whole project is still inside a folder (myproject/).
  47. - Exporting the project will not export the .wav and .png files which
  48. were imported.
  49. - myproject/ can be put directly inside a VCS (like svn or git) for
  50. version control, both game and source assets are kept track of.
  51. - If a team is working on the project, assets can be re-imported by
  52. other project members, because Godot keeps track of source assets
  53. using relative paths.
  54. Scene Organization
  55. ------------------
  56. Inside the game folder, a question that often arises is how to organize
  57. the scenes in the filesystem. Many developers try asset-type based
  58. organization and end up having a mess after a while, so the best answer
  59. is probably to organize them based on how the game works and not based
  60. on asset type. Here are some examples.
  61. If you were organizing your project based on asset type, it would look
  62. like this:
  63. ::
  64. game/engine.cfg
  65. game/scenes/scene1.scn
  66. game/scenes/scene2.scn
  67. game/textures/texturea.png
  68. game/textures/another.tex
  69. game/sounds/sound1.smp
  70. game/sounds/sound2.wav
  71. game/music/music1.ogg
  72. Which is generally a bad idea. When a project starts growing beyond a
  73. certain point, this becomes unmanageable. It's really difficult to tell
  74. what belongs to what.
  75. It's generally a better idea to use game-context based organization,
  76. something like this:
  77. ::
  78. game/engine.cfg
  79. game/scenes/house/house.scn
  80. game/scenes/house/texture.tex
  81. game/scenes/valley/canyon.scn
  82. game/scenes/valley/rock.scn
  83. game/scenes/valley/rock.tex
  84. game/scenes/common/tree.scn
  85. game/scenes/common/tree.tex
  86. game/player/player.scn
  87. game/player/player.gd
  88. game/npc/theking.scn
  89. game/npc/theking.gd
  90. game/gui/main_screen/main_sceen.scn
  91. game/gui/options/options.scn
  92. This model or similar models allows projects to grow to really large
  93. sizes and still be completely manageable. Notice that everything is
  94. based on parts of the game that can be named or described, like the
  95. settings screen or the valley. Since everything in Godot is done with
  96. scenes, and everything that can be named or described can be a scene,
  97. this workflow is very smooth and easygoing.
  98. Cache Files
  99. -----------
  100. Godot uses a hidden file called ".fscache" at the root of the project.
  101. On it, it caches project files and is used to quickly know when one is
  102. modified. Make sure to **not commit this file** to git or svn, as it
  103. contains local information and might confuse another editor instance in
  104. another computer.
  105. *Juan Linietsky, Ariel Manzur, Distributed under the terms of the `CC
  106. By <https://creativecommons.org/licenses/by/3.0/legalcode>`__ license.*