basics.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <!DOCTYPE html>
  2. <html class="writer-html4" lang="en" >
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title>Basic concepts &mdash; Crown Manual 0.41.0 documentation</title>
  7. <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  8. <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  9. <!--[if lt IE 9]>
  10. <script src="_static/js/html5shiv.min.js"></script>
  11. <![endif]-->
  12. <script type="text/javascript">
  13. var DOCUMENTATION_OPTIONS = {
  14. URL_ROOT:'./',
  15. VERSION:'0.41.0',
  16. LANGUAGE:'None',
  17. COLLAPSE_INDEX:false,
  18. FILE_SUFFIX:'.html',
  19. HAS_SOURCE: true,
  20. SOURCELINK_SUFFIX: ''
  21. };
  22. </script>
  23. <script type="text/javascript" src="_static/jquery.js"></script>
  24. <script type="text/javascript" src="_static/underscore.js"></script>
  25. <script type="text/javascript" src="_static/doctools.js"></script>
  26. <script type="text/javascript" src="_static/js/theme.js"></script>
  27. <link rel="copyright" title="Copyright" href="copyright.html" />
  28. <link rel="next" title="Lua API reference" href="lua_api.html" />
  29. <link rel="prev" title="Introduction" href="introduction.html" />
  30. </head>
  31. <body class="wy-body-for-nav">
  32. <div class="wy-grid-for-nav">
  33. <nav data-toggle="wy-nav-shift" class="wy-nav-side">
  34. <div class="wy-side-scroll">
  35. <div class="wy-side-nav-search" >
  36. <a href="index.html" class="icon icon-home"> Crown Manual
  37. </a>
  38. <div class="version">
  39. 0.41.0
  40. </div>
  41. <div role="search">
  42. <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
  43. <input type="text" name="q" placeholder="Search docs" />
  44. <input type="hidden" name="check_keywords" value="yes" />
  45. <input type="hidden" name="area" value="default" />
  46. </form>
  47. </div>
  48. </div>
  49. <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
  50. <ul class="current">
  51. <li class="toctree-l1"><a class="reference internal" href="changelog.html">Changelog</a></li>
  52. <li class="toctree-l1"><a class="reference internal" href="introduction.html">Introduction</a></li>
  53. <li class="toctree-l1 current"><a class="current reference internal" href="">Basic concepts</a><ul>
  54. <li class="toctree-l2"><a class="reference internal" href="#the-source-directory">The source directory</a></li>
  55. <li class="toctree-l2"><a class="reference internal" href="#the-boot-directory-and-the-boot-config-file">The boot directory and the boot.config file</a></li>
  56. <li class="toctree-l2"><a class="reference internal" href="#the-data-directory">The data directory</a></li>
  57. <li class="toctree-l2"><a class="reference internal" href="#the-dataignore-file">The .dataignore file</a></li>
  58. <li class="toctree-l2"><a class="reference internal" href="#units-of-measurement">Units of measurement</a></li>
  59. </ul>
  60. </li>
  61. <li class="toctree-l1"><a class="reference internal" href="lua_api.html">Lua API reference</a></li>
  62. <li class="toctree-l1"><a class="reference internal" href="boot_config.html">boot.config reference</a></li>
  63. <li class="toctree-l1"><a class="reference internal" href="command_line.html">Command line reference</a></li>
  64. <li class="toctree-l1"><a class="reference internal" href="glossary.html">Glossary</a></li>
  65. <li class="toctree-l1"><a class="reference internal" href="copyright.html">License</a></li>
  66. </ul>
  67. <ul>
  68. <li class="toctree-l1"><a class="reference internal" href="hackers/index.html">Hackers</a></li>
  69. </ul>
  70. </div>
  71. </div>
  72. </nav>
  73. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  74. <nav class="wy-nav-top" aria-label="top navigation">
  75. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  76. <a href="index.html">Crown Manual</a>
  77. </nav>
  78. <div class="wy-nav-content">
  79. <div class="rst-content">
  80. <div role="navigation" aria-label="breadcrumbs navigation">
  81. <ul class="wy-breadcrumbs">
  82. <li><a href="index.html" class="icon icon-home"></a> &raquo;</li>
  83. <li>Basic concepts</li>
  84. <li class="wy-breadcrumbs-aside">
  85. <a href="_sources/basics.txt" rel="nofollow"> View page source</a>
  86. </li>
  87. </ul>
  88. <hr/>
  89. </div>
  90. <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
  91. <div itemprop="articleBody">
  92. <div class="section" id="basic-concepts">
  93. <h1>Basic concepts<a class="headerlink" href="#basic-concepts" title="Permalink to this headline">¶</a></h1>
  94. <div class="section" id="the-source-directory">
  95. <h2>The source directory<a class="headerlink" href="#the-source-directory" title="Permalink to this headline">¶</a></h2>
  96. <p>The source directory contains all the files that make up an application.</p>
  97. <p>There is no fixed structure for the files and folders in the source directory, you can organize
  98. your content as you see fit. You can for example decide to put all the textures and sounds in the
  99. &#8220;textures&#8221; and &#8220;sounds&#8221; folders, or maybe sort the content on a per-object basis by putting all the
  100. assets for an enemy in the &#8220;units/enemy&#8221; folder.</p>
  101. <p>There is, however, a small number of required files which are needed for the engine to start-up
  102. correctly:</p>
  103. <div class="code highlight-python"><div class="highlight"><pre>.
  104. ├── boot.config &lt;- First file loaded by the engine
  105. ├── boot.package &lt;- Package to load on boot
  106. ├── boot.lua &lt;- Lua script to launch on boot
  107. └── global.physics_config &lt;- Global physics-related configurations
  108. </pre></div>
  109. </div>
  110. </div>
  111. <div class="section" id="the-boot-directory-and-the-boot-config-file">
  112. <h2>The boot directory and the boot.config file<a class="headerlink" href="#the-boot-directory-and-the-boot-config-file" title="Permalink to this headline">¶</a></h2>
  113. <p>Any directory within <a class="reference internal" href="#the-source-directory">the source directory</a> containing the file named <code class="docutils literal"><span class="pre">boot.config</span></code> is a boot
  114. directory.</p>
  115. <p>The <code class="docutils literal"><span class="pre">boot.config</span></code> is the first file read by Crown; it specifies the package to load and the lua
  116. script to execute on boot and various other boot-time settings.
  117. See boot.config reference for details.</p>
  118. <p>Normally there is a single <code class="docutils literal"><span class="pre">boot.config</span></code> file, placed at the top of the source directory. This is
  119. the file which Crown looks at by default.</p>
  120. <p>In some circumstances is desirable to have multiple <code class="docutils literal"><span class="pre">boot.config</span></code> files.
  121. You can set which boot directory Crown should use with the switch <code class="docutils literal"><span class="pre">--boot-dir</span></code>.</p>
  122. <p>In the example below, a minimal <code class="docutils literal"><span class="pre">boot.config</span></code> file tells the engine to load the package <code class="docutils literal"><span class="pre">boot</span></code>
  123. and run the Lua script <code class="docutils literal"><span class="pre">lua/game</span></code>.</p>
  124. <div class="code highlight-python"><div class="highlight"><pre>cat boot.config
  125. boot_package = &quot;boot&quot; // Package to load on boot
  126. boot_script = &quot;lua/game&quot; // Lua script to execute on boot
  127. </pre></div>
  128. </div>
  129. </div>
  130. <div class="section" id="the-data-directory">
  131. <h2>The data directory<a class="headerlink" href="#the-data-directory" title="Permalink to this headline">¶</a></h2>
  132. <p>Crown reads source data from <a class="reference internal" href="#the-source-directory">the source directory</a> and compiles it into efficient binary
  133. representation. The result of the compilation process is stored in the data directory.</p>
  134. <div class="code highlight-python"><div class="highlight"><pre>.
  135. ├── data &lt;- Contains compiled data files
  136. | ├── a14e8dfa2cd... &lt;- Compiled file
  137. | ├── 72e3cc03787... &lt;- Another compiled file
  138. | └── ...
  139. ├── data_index.sjson &lt;- Used to convert resource IDs to human-readable names
  140. ├── last.log &lt;- Text log from the last engine execution
  141. └── temp &lt;- Temporary files from data compilers
  142. </pre></div>
  143. </div>
  144. </div>
  145. <div class="section" id="the-dataignore-file">
  146. <h2>The .dataignore file<a class="headerlink" href="#the-dataignore-file" title="Permalink to this headline">¶</a></h2>
  147. <p>The <code class="docutils literal"><span class="pre">.dataignore</span></code> file specifies files that Crown should ignore when compiling data.</p>
  148. <p>When Crown bumps into unknown files in the source directory, it reports an error and quits the
  149. compilation.
  150. This is often desired behavior, since you do not want non-essential data in your source directory.</p>
  151. <p>In all other cases, you should create a <code class="docutils literal"><span class="pre">.dataignore</span></code> in the source directory.</p>
  152. <p>Example:</p>
  153. <div class="code highlight-python"><div class="highlight"><pre>cat .dataignore
  154. # This is a comment.
  155. # Blank lines are ignored.
  156. # Everything else is simple glob pattern (*, ?).
  157. *.txt
  158. </pre></div>
  159. </div>
  160. </div>
  161. <div class="section" id="units-of-measurement">
  162. <h2>Units of measurement<a class="headerlink" href="#units-of-measurement" title="Permalink to this headline">¶</a></h2>
  163. <p>Crown uses MKS (meters, kilograms and seconds) units and radians for angles.</p>
  164. </div>
  165. </div>
  166. </div>
  167. </div>
  168. <footer>
  169. <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
  170. <a href="lua_api.html" class="btn btn-neutral float-right" title="Lua API reference" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
  171. <a href="introduction.html" class="btn btn-neutral float-left" title="Introduction" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
  172. </div>
  173. <hr/>
  174. <div role="contentinfo">
  175. <p>
  176. &#169; <a href="copyright.html">Copyright</a> Except where otherwise noted, content on this page is licensed under a CC-BY-SA 4.0 Int. License.
  177. </p>
  178. </div>
  179. Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
  180. <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
  181. provided by <a href="https://readthedocs.org">Read the Docs</a>.
  182. </footer>
  183. </div>
  184. </div>
  185. </section>
  186. </div>
  187. <script type="text/javascript">
  188. jQuery(function () {
  189. SphinxRtdTheme.Navigation.enable(true);
  190. });
  191. </script>
  192. </body>
  193. </html>