Castle Game Engine icon

Getting Started

1. Installation

1.1. Lazarus

If you use Lazarus for development:

  1. Open and compile the package castle_base.lpk You will find it in the castle_game_engine/packages/ subdirectory. Use the Lazarus menu item "Package -> Open Package File (.lpk)" to open the package file, press "Compile" in a dialog that appears.

    castle_base: Open Package File castle_base: Choose the file castle_base: Compile
  2. Then open and compile the package castle_window.lpk.

    Note: do not install the castle_window package.

    castle_window: Choose the file castle_window: Compile
  3. Finally, open and install the package castle_components.lpk. In the package dialog, the option to "Install" package is under the "Use" button.

    castle_components: Choose the file castle_components: Install castle_components: Confirm Lazarus rebuild

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

You're done:) Now compile and run from Lazarus any engine example. Open the project file (xxx.lpi) using Lazarus, and compile and run. A good examples to try at the beginning are examples/fps_game/fps_game.lpi and examples/lazarus/model_3d_viewer/.

From Lazarus, you can use the engine integrated with Lazarus forms (and the rest of the Lazarus Component Library) through the TCastleControl class. Or you can use Lazarus only as an editor and debugger, and use the engine without the Lazarus forms, initializing the window using the TCastleWindow class.

fps_game: Open Project fps_game: Choose the file fps_game: Run fps_game: Running!
Watch the movie showing the Lazarus installation process.

1.2. Alternative: without Lazarus (bare FPC)

If you don't use Lazarus (only command-line FPC):

Our engine can be used without the LCL (Lazarus Component Library) through the TCastleWindow class. To compile the engine and applications without the help of Lazarus, you have a couple of options:

  1. Use simple shell scripts that call FPC with proper command-line options. They pass to FPC file castle-fpc.cfg that contains engine paths and compilation options. Just try compiling any example program this way. A good examples to try at the beginning is examples/fps_game/fps_game.lpr, so do

    cd examples/fps_game/

    And run the resulting executable (run ./fps_game on Unix, or fps_game.exe on Windows). You can use a similar approach as the script for your own programs.

  2. Once you get friendly with the engine, we highly advice using our build tool to compile and package your games. The build tool reads the project configuration from the CastleEngineManifest.xml file. It provides a lot of cool options, e.g. can easily package your Android game, or prepare compressed versions of your textures.

  3. Other option is to compile the engine units by executing make inside the castle_game_engine/ directory. This uses FpMake. Then add the path with compiled units to your fpc.cfg file by adding a line like -Fu.../castle_game_engine/units/x86_64-linux (see FPC documentation "Configuration file" to know where you can find your fpc.cfg file).

2. Install the libraries

Programs developed using our engine (engine examples, and your own programs too) can use a couple of libraries.

  • On Windows the libraries (DLL files) are in the downloaded engine archive. They are in:
    • (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/ .

    You can just copy the DLL files to every directory with .exe files that you compile with our engine.

    Or you can modify your $PATH environment variable to include the directory where these libraries are. Google "windows how to modify path" if you're not sure how to do this. Remember to restart the appropriate programs, to make them use the new value of $PATH.

    Be sure to use the DLL files corresponding to your compiler — if you use FPC/Lazarus for 32-bits, then you make executable for 32-bits, and you should use DLLs for 32-bits. Even if you work on 64-bit Windows.

  • On Linux and FreeBSD you should install the following libraries using your favorite package Manager: LibPng, ZLib, GtkGLExt OpenAL, FreeType and VorbisFile. Remember to install -dev versions of these libraries too (if you're under Debian or similar distribution) to be able to compile programs that link to these libraries.

  • On Mac OS X: Mac OS X requirements are listed here.

Now go to our manual!
..and create some cool games!:)

It's really easy, and if you have any questions — please ask on the forum!

Suppport on Patreon