godot_design_philosophy.rst 7.3 KB

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