2. Download and install the engine, try the demos

Short usage instructions

If you haven't done it yet, download the engine source code with examples.

  • If you want to develop using Lazarus forms:

    1. In Lazarus, open and compile the package castle_base.lpk You will find it in the castle_game_engine/packages/ subdirectory.
    2. Then open and compile the package castle_window.lpk. (You should not install this package.)
    3. Finally, open and install the package castle_components.lpk. (It will also automatically install the package castle_base, as a dependency. That's cool.)

    Once castle_components.lpk is successfully installed, Lazarus restarts, and you should see the "Castle" tab with our components.

  • Alternatively, our engine can be used without Lazarus and LCL (Lazarus Component Library). Only FPC (Free Pascal Compiler) is required. Many of the example programs use our own CastleWindow unit to communicate with window manager, and they do not depend on Lazarus LCL. You can use command-line xxx_compile.sh scripts (or just call make examples) to compile them using FPC.

    In this case, to develop your own programs, you have several options:

    1. Use Lazarus just to manage a custom application:

      • Once, compile (do not install) the packages castle_base.lpk and then castle_window.lpk (from castle_game_engine/packages/ subdirectory).
      • Create new project using Lazarus "New Project" menu item.
      • Choose "Custom Application" (or "Project->Simple Program").
      • Using "Project->Project Inspector" window add a "New Requirement" and choose castle_base package.
      • Then add another requirement and choose castle_window package.
      In this case, you will not design your forms visually using Lazarus. But you will still use Lazarus as a powerful Object Pascal IDE, to edit and compile and debug your programs.
    2. Or compile your projects using our build tool. Edit and debug them using whatever tool you like.

    3. Or compile the engine with make and add the engine unit output path (like .../castle_game_engine/units/i386-linux/) to your fpc.cfg file (see FPC documentation "Configuration file" to know where you can find your fpc.cfg file).

Make sure you have installed the necessary libraries

The required libraries are mentioned near the engine download. Under Windows, you can get the necessary DLLs from the engine sources you just unpacked:
  • (32-bit) castle_game_engine/tools/build-tool/data/external_libraries/i386-win32/ or
  • (64-bit) castle_game_engine/tools/build-tool/data/external_libraries/x86_64-win64/
Place these DLL files somewhere on your $PATH, or just copy them to every directory with .exe files that you compile with our engine.

Try the examples

We suggest you compile and run now our example project examples/fps_game/fps_game.lpr . Also look at it's source code for a complete demo of various concepts presented in this tutorial.

If you use Lazarus LCL, try also compiling and running the demo inside examples/lazarus/model_3d_viewer/.

To run the example, simply open it's project .lpi in Lazarus and run. If you compiled the necessary packages previously (see above point), the examples should just run. If you prefer to use the command-line, you can also compile all examples using the make examples command.