godot_design_philosophy.rst 7.3 KB

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