Castle Game Engine icon

Getting Started

1. Video Introduction

If you like to learn by watching, enjoy this video introduction to the engine and editor:

2. Using Castle Game Engine Editor

  1. First install Lazarus with FPC.

  2. Download the latest Castle Game Engine. Unpack the engine ZIP wherever you like.

  3. Inside the unpacked castle_game_engine, you will find a subdirectory bin. Run the castle-editor executable inside.

  4. Configure FPC and Lazarus locations in editor Preferences, if needed.

  5. Create a new project, using one of the suggested New Project templates. These templates have been designed to show you most important features of our engine, along with the most advised way to use them.

  6. Compile and Run the project using the editor Run menu.

  7. That's it! The world is your oyster now :)

    Open and try more example projects from the engine examples subdirectory. Almost all engine examples have a CastleEngineManifest.xml file and can be build using the editor (or command-line build tool).

    In either case, the project configuration is defined by a CastleEngineManifest.xml file.

The editor and build tool are most natural to build applications that do not depend on LCL (Lazarus Component Library). This means that you should initialize your game window using the TCastleWindowBase class. Our documentation and most examples follow this approach too.

3. Using Lazarus

To 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 TCastleControlBase 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 TCastleWindowBase class.

fps_game: Open Project fps_game: Choose the file fps_game: Run fps_game: Running!

Watch the movie showing the Lazarus installation process.

Another option is to build and install the engine using FpMake.

4. Install the libraries

Programs developed using our engine use some external libraries.

  • On Windows the libraries (dll files) are in the downloaded engine archive.

    If you use our editor or command-line build tool, the dll files will be automatically copied alongside your exe file, so you don't have to do anything. Seriously, you can stop reading now :)

    If you use some other method of compilation, you need to manually make sure that the dll files are in the correct place.

    The dll files are in:

    You can copy these dll files to every directory with exe files of your application.

    Or you can modify your PATH environment variable to include the directory where the dll files are. If you're not sure how to set the environment variable, search the Internet (e.g. these are quick instructions how to do it on various Windows versions). 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 target platform. For example, if you use FPC/Lazarus for 32-bits, then you make executable for 32-bits (by default), and you should use dll for 32-bits. Even if you work on a 64-bit Windows.

  • On Linux and FreeBSD, we use the following libraries:

    1. OpenGL (essential for the engine to work; used to render)
    2. LibPng (to open png files more efficiently)
    3. ZLib (to unpack gzip files, also used by LibPng)
    4. OpenAL (to play sound)
    5. FreeType (to load font files)
    6. VorbisFile (to load OggVorbis files)

    The first 3 (OpenGL, LibPng, Zlib) are definitely present on all reasonable desktop installations. The others are typicallly installed too, but it will not hurt to document somewhere for users "Please make sure you have these libraries installed: ...".

    On your (developer) system, you will need the development versions of some of these libraries. This allows to build programs that link to these libraries. On Debian systems, this command should install everything you need:

    sudo apt install libgtk2.0-dev libgl1-mesa-dev

    Note that we link to many libraries dynamically using "dlopen" Unix mechanism. So it is not necessary to install e.g. libpng-dev or libfreetype6-dev.

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

5. 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 us on Patreon