basics.html 12 KB

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