Improvements to cross-platform building: choose platform in editor, optionally allow case-insensitive URLs on case-sensitive filesystems, run Windows builds through WINE on Unix

Posted on

Choose platfom in CGE editor
Seamlessly running Windows application through WINE on Linux
  1. You can now choose the platform (Windows, Linux, Android, iOS…) to build and run from the editor. This platform is then used by compile, run, package, install build tool commands. This means that, if you have cross-compilers set up (hint: use fpcupdeluxe) then you can now easily build for various platforms, right from the GUI editor, without resorting to command-line and playing with environment variables.

  2. Another new feature, also related to the cross-platform development, is specifically for Linux/FreeBSD developers that want to target Windows too:

    You can now run Windows application on Unix seamlessly — if only you have WINE installed. The build tool, as well as GUI editor, will invoke wine / wine32 / wine64 under the hood, if you run Windows build on Unix. From the command-line, it means you use castle-engine run --os=win64 --cpu=x86_64 (or --os=win32 --cpu=i386 for 32-bit Windows) while your current (source, host) OS is Unix.

    Together, this means that if you have FPC cross-compiler from Linux to Windows installed (again, use fpcupdeluxe — it’s easy 🙂 ), and WINE installed (it should be included in the packages of all Linux distributions), then you can just switch in CGE editor platform to Windows, and press F9, and see the Windows application being compiled + run on your Linux without any fuss. The compilation / testing is then equally easy as for normal native Linux build.

  3. To make things balanced, we also have one new feature for Windows developers to make it easier for them to build apps for Unix (Linux, FreeBSD) desktops:

    You can set trivial global boolean CastleDataIgnoreCase, to easily run application with castle-data URLs that have wrong case on a case-sensitive filesystem. E.g. your file in the data directory may be called my_texture.png. Normally, accessing it by URL like castle-data:/My_Texture.png doesn’t work on Unix, as the file system honors the case (in contrast to Windows, where it works OK).

    Setting CastleDataIgnoreCase means that we search for the file name (and all directory components on the way) ignoring the upper/lower letters difference. It will raise an error only when it is impossible (no such file found, or ambiguous, e.g. you have both my_texture.png and My_Texture.png on disk — this is perfectly possible on case-sensitive filesystems).

    While this is slower (so we don’t really advise it as the “final solution”), but it is useful to quickly deploy applications tested mostly on Windows into Unix. In the long run, we still advise you to just honor the case, and thus make things work without CastleDataIgnoreCase, but using CastleDataIgnoreCase is now a possible and quick solution when you need it.

Comments on the forum ➤

Android and iOS improvements, Docker and releases upgrade to FPC 3.2.2

Posted on

detect_scene_hit example screenshot

A few loosely connected improvements for building and mobile devices:


  1. Fixed building on Android when the project folder contained spaces. We no longer use ndk-build that cannot cope with that.

  2. Fixed (well, workarounded) crashes on Snapdragon (Adreno) Android devices when using parallax bump mapping.

  3. Updated Android prerequisites documentation. Using latest Android SDK with latest Java is OK now, and we no longer need to use ancient Java 8. Latest Android SDK is OK with Java 11, and just using default-jdk package in Debian stable works.


  1. Compilation for iOS with FPC 3.2.2 is fixed. Just like FPC, we now define iOS as a separate OS from “darwin”, and thus we’re ready for macOS 11 (desktops running on Arm64 CPU).

  2. Updated iOS documentation. Installing iOS cross-compilers using fpcupdeluxe works cool now.

Docker and releases:

  1. Our Docker image has been upgraded. It is now based on Debian buster (current stable) instead of stretch (oldstable). We kept relying on stretch (oldstable) for a long time, as Android SDK required ancient Java 8 — luckily this is no longer the case.

  2. Our Docker image contains now latest FPC version 3.2.2 and it is the default FPC version. Also the FPC trunk revision has been updated to latest revisions on 2021-07-18.

  3. This also means that CGE binary releases are now compiled with FPC 3.2.2 (instead of previous 3.2.0).

I did not really have any good image for this post, so attaching a screenshot from new examples/3d_rendering_processing/detect_scene_hit 🙂 It is a simple demo of TCastleViewport.TransformUnderMouse.

Comments on the forum ➤

Platformer demo released on

Posted on

Platformer demo - title screen

Have a lovely Sunday!

And play our platformer demo, if you haven’t already 🙂 We have compiled version of the game, for Windows and Linux, ready here:

You can download it manually as a zip file, or using comfortable App.

We have also updated Castle Game Engine page to represent the engine better.

For developers, an additional treat is the examples/platformer/ directory that contains the shell script and manifest files that show how to 100% automatically release your game on CGE. You can combine our build tool and butler to do this.

The platformer demo was developed by Andrzej Kilijański. For more information, see the README and the previous news about it.

Last but not least, after playing, you can watch the movie where Eugene Loza managed to play through the entire game without firing a single shot 🙂 For a more typical gameplay, pick up the weapon and fire with a Space key! Spoiler warning – of course watching the movie will kind of spoil the game for you. It’s probably more fun to play it yourself first:)

Comments on the forum ➤

New manual chapter that introduces editor and states, more manual and website updates, “Register Lazarus Packages” button

Posted on

Designing user interface in Castle Game Engine editor - resized biplane
Designing user interface in Castle Game Engine editor - image preview
State events demo - resulting application

I am deep in making big updates to the manual, to document the usage of editor and other concepts that become important during the CGE 7.0 development.

We start with new 1st and 2nd manual chapters:

  1. Installation and building your first application

  2. Designing user interface and handling events (press, update) within the state

Go ahead and read them now, whether you’re a seasoned CGE user or a new one 🙂

Details – what and why:

  • The manual beginning is now much simpler than it was, replacing previous Getting Started (was needlessly complicated), Opening the window (unnecessary), Window events (obsolete, as you should now use TUIState events). The new pages focus clearly on doing things the way we advise — which is using our visual editor.

    In particular Designing user interface and handling events (press, update) within the state chapter is actually an introduction to using the editor, from zero-knowledge. It shows how to modify the design, add images, and then access them from code and use basic TUIState methods.

  • While doing it, I also introduced new utilities TCastleUserInterface.ContainerToLocalPosition and reverse TCastleUserInterface.LocalToContainerPosition. It became apparent they are useful, both for internal and outside usage.

  • I also introduced a button “Register Lazarus Packages” in the editor preferences. This button simplifies one installation step, which allowed to make chapter Installation and building your first application shorter 🙂

  • The installation of castle_components package, and in general dealing with TCastleControlBase in LCL, has been deemphasized, and moved to new chapter Engine control to put on Lazarus form. Nothing changes with regards to our support (you have a choice between TCastleWindowBase and TCastleControlBase), but the manual is now more focused on the advised approach for “normal CGE applications”, which is to use TCastleWindowBase as set up by our templates.

  • I made a link to our Castle Game Engine YouTube channel much more prominent, putting “Videos” right on the website menu bar.

  • I also made some other minor website changes. New font (Inter), better size of the download icons, better news list (directly show the sharing buttons, and link to forum without an extra click).

Comments on the forum (1) ➤

Packaging to Android App Bundle

Posted on

Android App Bundle

You can now easily package Android games using Castle Game Engine to the AAB format (instead of APK). New Build Tool command-line options allow to execute:

  • castle-engine package --target=android --package-format=android-app-bundle

    Will package to the new AAB format.

  • castle-engine package --target=android --package-format=android-apk

    Will package to the traditional APK format. The --package-format=android-apk is right now the default behavior, equivalent to also using --package-format=default on Android — time will tell whether we will change this default to AAB.

Why the new Android package format?

Starting August 2021 (next month!) all new apps published on Google Play Store are required to be uploaded in Android App Bundle (AAB) format and from November 2021 all updates to existing apps at Google Play Store will be required to use AAB format. Also, uploading apps in AAB format overcomes Google Play Store 100 MB limitation on a project build, which is especially important for games, as different assets can take up a lot of space and reducing their quality is not always a good option.

Note that we still support packaging to regular Android Packages (APK) that can be instantly installed to an Android device and it still remains a default packaging format for Android platform, as it is very convenient for development purposes or for distribution through alternative to Play Store platforms, e.g. uploading to

Android App Bundle (AAB) is a collection of prebuilt resources targeted for different user devices (such as Android version, CPU architecture, Screen resolution). Play Store then automatically generates an APK based on user configuration. Note that it also means that AAB package cannot be directly installed on a mobile device/emulator and therefore for debugging and internal testing APK is still a necessary format.

Comments on the forum ➤

Adding behaviors in CGE editor (TCastleBillboard, TCastleSoundSource)

Posted on

Design: Werewolf, from a sprite sheet, is also a billboard and emits a 3D sound
Werewolf, from a sprite sheet, is also a billboard and emits a 3D sound

You can now add/remove behaviors using the CGE editor. “Behaviors” are components that enhance the behavior of the parent TCastleTransform. We have a few of them included in CGE, and you can define more (“3D FPS Game” template shows a trivial behavior of an enemy).

If you come from Unity, know that “creating TCastleBehavior” is now the closest equivalent to Unity “creating MonoBehaviour”.

The behaviors you can add now using the editor are:

  1. TCastleBillboard. Turns any TCastleTransform into a billboard (visually, in the editor, too). Billboard automatically rotates (around some axis, or freely) to face the camera. TCastleBillboard is now our advised way to make billboards in CGE (much simpler to use than X3D node TBillboardNode, which we advised in the past).

    It exposes AxisOfRotation, by default +Y axis. Simply set it to zero Vector3(0, 0, 0) to rotate the transformation freely, to always face the camera.

  2. TCastleSoundSource. This makes the parent TCastleTransform emit a sound. Such sound has a 3D position and can be spatialized, which means that distance of the emitter affects the volume, and position of the emitter affects whether you hear it more from the left or right side. More on this in later news about sounds 🙂

A simple example of it is now in examples/creature_behaviors. The wolf is a sprite sheet, and a billboard, and it emits a “howling” sound.

Comments on the forum ➤

Non-Visual Components in Editor

Posted on

Fixed-camera demo (with new sounds)
Non-Visual Components menu
Sound list editing (non-visual component design)

You can now edit any TComponent descendant in CGE editor. I expect to use it intensively to design basically everything in the editor.

The non-visual components registered automatically (and thus available by default in CGE editor) are:

  • Fonts: TCastleBitmapFont, TCastleFontFamily, TCastleFont — described in the previous news about fonts.

  • TCastleSound — describes a sound file to be played. More on this in the upcoming news about sounds and the updated manual chapter about it.

  • TCastleComponent which is like standard TComponent but it can have non-visual children components managed by TCastleComponent.AddNonVisualComponent method and friends. These “non-visual children components” do not do anything, but they are serialized along with the parent component, thus you can organize your information in a tree.

    Oh, and sound and font classes mentioned above also descend from TCastleComponent. And all visual classes, like TCastleUserInterface and TCastleTransform can have non-visual components too, so e.g. a UI design root, or a TCastleLabel, can “store” the reference to a font. This is all flexible, so you can use the system to arrange information in any tree you like.

We also have new menu items to create a design that contains only non-visual components:

  • Design -> New Non-Visual Component (Empty Component As Root) (root is TCastleComponent)
  • Design -> New Non-Visual Component (Custom Root)

E.g. you can use it to store TCastleFont or TCastleSound collection in a file.

An example of using this approach to manage a list of sounds is in examples/fixed_camera_game, the design file data/sounds/all_sounds.castle-component defines all the sounds. The code that handles it is in code/gamesound.pas file. This is our new approach to define a “repository” of sounds, and it will soon be documented prominently in the manual and will deprecate the existing approach to define sound repository by an XML file.

This is our preferred editing and serialization approach for every TComponent. And so our preferred serialization for everything is to use RTTI with TComponent, which makes our CGE editor “complete” in the sense that it is now more universal than only “editor for CGE UI / transforms”, it is now “editor for everything in CGE”.

The non-visual components can be saved / loaded to a file with .castle-component extension.

The TCastleComponent also exposes a nice general mechanism to serialize children lists, using TCastleComponent.CustomSerialization and TSerializationProcess. It is now used to serialize regular children (TCastleUserInterface children of TCastleUserInterface, TCastleTransform children of TCastleTransform) and NonVisualComponents children (of any TCastleComponent) and Behaviors (of any TCastleTransform).

We also improved related JSON serialization code. It’s now a bit simpler (no more special $Children code, the TCastleComponent.CustomSerialization now covers this use-case). We write $$ClassName earlier (JSON is more readable for humans), we don’ write empty $Children (JSON simpler for humans).

Comments on the forum (2) ➤

Kryftolike – a roguelike-like hide-and seek game using Castle Game Engine

Posted on

Kryftolike screenshot
Kryftolike screenshot
Kryftolike screenshot
Kryftolike screenshot

A new Free and Open Source game made in Castle Game Engine: Kryftolike – a hide-and-seek roguelite game where the Player hides from monsters and seeks treasure in an infinite procedurally-generated map.  Danger awaits around every corner.

Source code: Kryftolike at GitLab (Also an example of efficient 2D batched rendering, creation of custom UI elements in Castle Game Engine)

Downloadable binaries for Android, Windows and Linux: Kryftolike at

Comments on the forum ➤