godot_design_philosophy.rst 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. .. _doc_godot_design_philosophy:
  2. Godot's design philosophy
  3. =========================
  4. Now that you've gotten your feet wet, let's talk about Godot's design.
  5. **Every game engine is different and fits different needs.**
  6. Not only do they offer a range of features, but the design of each engine
  7. is unique. This leads to different workflows and different ways to form
  8. your games' structures. This all stems from their respective design philosophies.
  9. This page is here to help you understand how Godot works, starting
  10. with some of its core pillars. It is not a list of available features, nor
  11. is it an engine comparison. To know if any engine can be a good fit for
  12. your project, you need to try it out for yourself and
  13. understand its design and limitations.
  14. Please watch
  15. `Godot explained in 7 minutes <https://www.youtube.com/watch?v=yS9cuu5o5Ug>`_
  16. if you're looking for an overview of the engine's features.
  17. Object-oriented design and composition
  18. --------------------------------------
  19. Godot embraces object-oriented design at its core with its flexible
  20. scene system and Node hierarchy. It tries to stay away from strict
  21. programming patterns to offer an intuitive way to structure your game.
  22. For one, Godot lets you **compose or aggregate** scenes.
  23. It's like nested prefabs: you can create a BlinkingLight scene and
  24. a BrokenLantern scene that uses the BlinkingLight.
  25. Then, create a city filled with BrokenLanterns.
  26. Change the BlinkingLight's color, save, and all the
  27. BrokenLanterns in the city will update instantly.
  28. On top of that, you can **inherit** from any scene.
  29. A Godot scene could be a Weapon, a Character, an Item, a Door, a Level,
  30. part of a level… anything you'd like. It works like a class in pure code,
  31. except you're free to design it by using the editor, using only the
  32. code, or mixing and matching the two.
  33. It's different from prefabs you find in several 3D engines, as you can
  34. then inherit from and extend those scenes. You may create a Magician
  35. that extends your Character. Modify the Character in the editor and the Magician
  36. will update as well. It helps you build your projects so that their
  37. structure matches the game's design.
  38. |image0|
  39. Also note that Godot offers many different types of objects called
  40. nodes, each with a specific purpose. Nodes are part of a tree and always
  41. inherit from their parents up to the Node class. Although the engine
  42. does feature some nodes like collision shapes that a parent physics
  43. body will use, most nodes work independently from one another.
  44. In other words, Godot's nodes do not work like components in some
  45. other game engines.
  46. |image1|
  47. Sprite2D is a Node2D, a CanvasItem and a Node. It has all the properties
  48. and features of its three parent classes, like transforms or the ability
  49. to draw custom shapes and render with a custom shader.
  50. All-inclusive package
  51. ---------------------
  52. Godot tries to provide its own tools to answer most common
  53. needs. It has a dedicated scripting workspace, an animation editor, a
  54. tilemap editor, a shader editor, a debugger, a profiler,
  55. the ability to hot-reload locally and on remote devices, etc.
  56. |image2|
  57. The goal is to offer a full package to create games and a continuous
  58. user experience. You can still work with external programs as long as
  59. there is an import plugin available in Godot for it. Or you can create one, like the `Tiled
  60. Map Importer <https://github.com/vnen/godot-tiled-importer>`__.
  61. That is also partly why Godot offers its own programming language
  62. GDScript along with C#. GDScript is designed for the needs
  63. of game developers and game designers, and is tightly integrated in
  64. the engine and the editor.
  65. GDScript lets you write code using an indentation-based syntax,
  66. yet it detects types and offers a static language's quality of auto-completion.
  67. It is also optimized for gameplay code with built-in types like Vectors and Colors.
  68. Note that with GDExtension, you can write high-performance code using compiled
  69. languages like C, C++, Rust, D, Haxe, or Swift without recompiling the engine.
  70. Note that the 3D workspace doesn't feature as many tools as the 2D workspace.
  71. You'll need external programs or add-ons to edit terrains, animate complex characters, and so on.
  72. Godot provides a complete API to extend the editor's functionality using
  73. game code. See `The Godot editor is a Godot game`_ below.
  74. |image4|
  75. *A State Machine editor plugin in Godot 2 by kubecz3k. It lets you
  76. manage states and transitions visually.*
  77. Open source
  78. -----------
  79. Godot offers a fully open source codebase under the **MIT license**.
  80. This means all the technologies that ship with it have to be Free
  81. (as in freedom) as well.
  82. For the most part, they're developed from the ground up by contributors.
  83. Anyone can plug in proprietary tools for the needs of their projects —
  84. they just won't ship with the engine. This may include Google AdMob,
  85. or FMOD. Any of these can come as
  86. third-party plugins instead.
  87. On the other hand, an open codebase means you can **learn from and extend
  88. the engine** to your heart's content. You can also debug games easily,
  89. as Godot will print errors with a stack trace, even if they come from the engine itself.
  90. .. note::
  91. This **does not affect the work you do with Godot** in any way: there's
  92. no strings attached to the engine or anything you make with it.
  93. Community-driven
  94. ----------------
  95. **Godot is made by its community, for the community, and for all game
  96. creators out there.** It's the needs of the users and open discussions
  97. that drive the core updates. New features from the core developers often
  98. focus on what will benefit the most users first.
  99. That said, although a handful of core developers work on it full-time,
  100. the project has thousands of contributors at the time of writing. Benevolent
  101. programmers work on features they may need themselves, so you'll see
  102. improvements in all corners of the engine at the same time in every
  103. major release.
  104. The Godot editor is a Godot game
  105. --------------------------------
  106. The Godot editor runs on the game engine. It uses the engine's own UI
  107. system, it can hot-reload code and scenes when you test your projects,
  108. or run game code in the editor. This means you can **use the same code**
  109. and scenes for your games, or **build plugins and extend the editor.**
  110. This leads to a reliable and flexible UI system, as it powers the editor
  111. itself. With the ``@tool`` annotation, you can run any game code in the editor.
  112. |image5|
  113. *RPG in a Box is a voxel RPG editor made with Godot 2. It uses Godot's
  114. UI tools for its node-based programming system and for the rest of the
  115. interface.*
  116. Put the ``@tool`` annotation at the top of any GDScript file and it will run
  117. in the editor. This lets you import and export plugins, create plugins
  118. like custom level editors, or create scripts with the same nodes and API
  119. you use in your projects.
  120. .. note::
  121. The editor is fully written in C++ and is statically compiled into the
  122. binary. This means you can't import it as a typical project that would have a
  123. ``project.godot`` file.
  124. Separate 2D and 3D engines
  125. --------------------------
  126. Godot offers dedicated 2D and 3D rendering engines. As a result, **the
  127. base unit for 2D scenes is pixels.** Even though the engines are
  128. separate, you can render 2D in 3D, 3D in 2D, and overlay 2D sprites and
  129. interfaces over your 3D world.
  130. .. |image0| image:: img/engine_design_01.png
  131. .. |image1| image:: img/engine_design_02.png
  132. .. |image2| image:: img/engine_design_03.png
  133. .. |image4| image:: img/engine_design_fsm_plugin.png
  134. .. |image5| image:: img/engine_design_rpg_in_a_box.png