basics.html 12 KB

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