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. We 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. it can easily package your Android or iOS game, or prepare compressed versions of your textures. Try it out on the command-line:

    # Line below is just an example for Unix, the goal is to put castle-engine binary on $PATH
    sudo mv tools/build-tool/castle-engine /usr/local/bin
    # Line below is just an example for Unix, the goal is to define $CASTLE_ENGINE_PATH
    export CASTLE_ENGINE_PATH=`pwd`
    # Test that it works!
    cd examples/fps_game/
    castle-engine compile
  2. Or you can use a simple shell script that calls FPC with proper command-line options. Make sure to pass to FPC file castle-fpc.cfg that contains engine paths and compilation options. Just try compiling any example program this way, for example to compile examples/fps_game/fps_game.lpr do this:

    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.

  3. Other option is to compile the engine using FpMake.

    fpc fpmake.pp
    # If the above doesn't work, you usually need to define FPC units dir
    # ./fpmake --globalunitdir=<my-fpc-directory>/units/

    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). And then, just use our units in your game code, and compile it in any way you like (like fpc mygame.lpr on the command-line).

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:

    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. For example, 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 a 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.

3. Read the manual

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!

Support on Patreon