godot_design_philosophy.rst 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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 5 minutes <https://www.youtube.com/watch?v=KjX5llYZ5eQ>`_
  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, or Python (using the Cython compiler)
  70. without recompiling the engine.
  71. Note that the 3D workspace doesn't feature as many tools as the 2D workspace.
  72. You'll need external programs or add-ons to edit terrains, animate complex characters, and so on.
  73. Godot provides a complete API to extend the editor's functionality using
  74. game code. See `The Godot editor is a Godot game`_ below.
  75. |image4|
  76. *A State Machine editor plugin in Godot 2 by kubecz3k. It lets you
  77. manage states and transitions visually.*
  78. Open source
  79. -----------
  80. Godot offers a fully open source codebase under the **MIT license**.
  81. This means all the technologies that ship with it have to be Free
  82. (as in freedom) as well.
  83. For the most part, they're developed from the ground up by contributors.
  84. Anyone can plug in proprietary tools for the needs of their projects —
  85. they just won't ship with the engine. This may include Google AdMob,
  86. or FMOD. Any of these can come as
  87. third-party plugins instead.
  88. On the other hand, an open codebase means you can **learn from and extend
  89. the engine** to your heart's content. You can also debug games easily,
  90. as Godot will print errors with a stack trace, even if they come from the engine itself.
  91. .. note::
  92. This **does not affect the work you do with Godot** in any way: there's
  93. no strings attached to the engine or anything you make with it.
  94. Community-driven
  95. ----------------
  96. **Godot is made by its community, for the community, and for all game
  97. creators out there.** It's the needs of the users and open discussions
  98. that drive the core updates. New features from the core developers often
  99. focus on what will benefit the most users first.
  100. That said, although a handful of core developers work on it full-time,
  101. the project has over 600 contributors at the time of writing. Benevolent
  102. programmers work on features they may need themselves, so you'll see
  103. improvements in all corners of the engine at the same time in every
  104. major release.
  105. The Godot editor is a Godot game
  106. --------------------------------
  107. The Godot editor runs on the game engine. It uses the engine's own UI
  108. system, it can hot-reload code and scenes when you test your projects,
  109. or run game code in the editor. This means you can **use the same code**
  110. and scenes for your games, or **build plugins and extend the editor.**
  111. This leads to a reliable and flexible UI system, as it powers the editor
  112. itself. With the ``@tool`` annotation, you can run any game code in the editor.
  113. |image5|
  114. *RPG in a Box is a voxel RPG editor made with Godot 2. It uses Godot's
  115. UI tools for its node-based programming system and for the rest of the
  116. interface.*
  117. Put the ``@tool`` annotation at the top of any GDScript file and it will run
  118. in the editor. This lets you import and export plugins, create plugins
  119. like custom level editors, or create scripts with the same nodes and API
  120. you use in your projects.
  121. .. note::
  122. The editor is fully written in C++ and is statically compiled into the
  123. binary. This means you can't import it as a typical project that would have a
  124. ``project.godot`` file.
  125. Separate 2D and 3D engines
  126. --------------------------
  127. Godot offers dedicated 2D and 3D rendering engines. As a result, **the
  128. base unit for 2D scenes is pixels.** Even though the engines are
  129. separate, you can render 2D in 3D, 3D in 2D, and overlay 2D sprites and
  130. interfaces over your 3D world.
  131. .. |image0| image:: img/engine_design_01.png
  132. .. |image1| image:: img/engine_design_02.png
  133. .. |image2| image:: img/engine_design_03.png
  134. .. |image4| image:: img/engine_design_fsm_plugin.png
  135. .. |image5| image:: img/engine_design_rpg_in_a_box.png