basics.rst 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. Basic concepts
  2. ==============
  3. The source directory
  4. --------------------
  5. The source directory contains all the files that make up an application.
  6. There is no fixed structure for the files and folders in the source directory, you can organize
  7. your content as you see fit. You can for example decide to put all the textures and sounds in the
  8. "textures" and "sounds" folders, or maybe sort the content on a per-object basis by putting all the
  9. assets for an enemy in the "units/enemy" folder.
  10. There is, however, a small number of required files which are needed for the engine to start-up
  11. correctly:
  12. .. code::
  13. .
  14. ├── boot.config <- First file loaded by the engine
  15. ├── boot.package <- Package to load on boot
  16. ├── boot.lua <- Lua script to launch on boot
  17. └── global.physics_config <- Global physics-related configurations
  18. The boot directory and the boot.config file
  19. -------------------------------------------
  20. Any directory within `the source directory`_ containing the file named ``boot.config`` is a boot
  21. directory.
  22. The ``boot.config`` is the first file read by Crown; it specifies the package to load and the lua
  23. script to execute on boot and various other boot-time settings.
  24. See `boot.config file reference`_ for more details.
  25. Normally there is a single ``boot.config`` file, placed at the top of the source directory. This is
  26. the file which Crown looks at by default.
  27. In some circumstances is desirable to have multiple ``boot.config`` files.
  28. You can set which boot directory Crown should use with the switch ``--boot-dir``.
  29. In the example below, a minimal ``boot.config`` file tells the engine to load the package ``boot``
  30. and run the Lua script ``lua/game``.
  31. .. code::
  32. $ cat boot.config
  33. boot_package = "boot" // Package to load on boot
  34. boot_script = "lua/game" // Lua script to execute on boot
  35. The data directory
  36. --------------------
  37. Crown reads source data from `the source directory`_ and compiles it into efficient binary
  38. representation. The result of the compilation process is stored in the data directory.
  39. .. code::
  40. .
  41. ├── data <- Contains compiled data files
  42. | ├── a14e8dfa2cd... <- Compiled file
  43. | ├── 72e3cc03787... <- Another compiled file
  44. | └── ...
  45. ├── data_index.sjson <- Used to convert resource IDs to human-readable names
  46. ├── last.log <- Text log from the last engine execution
  47. └── temp <- Temporary files from data compilers
  48. The .dataignore file
  49. ----------------------
  50. The ``.dataignore`` file specifies files that Crown should ignore when compiling data.
  51. When Crown bumps into unknown files in the source directory, it reports an error and quits the
  52. compilation.
  53. This is often desired behavior, since you do not want non-essential data in your source directory.
  54. In all other cases, you should create a ``.dataignore`` in the source directory.
  55. Example:
  56. .. code::
  57. $ cat .dataignore
  58. # This is a comment.
  59. # Blank lines are ignored.
  60. # Everything else is simple glob pattern (*, ?).
  61. *.txt
  62. Units of measurement
  63. --------------------
  64. Crown uses MKS (meters, kilograms and seconds) units and radians for angles.