Engine news (6.5 release snapshots, improvements to editor, TCastleWindowBase, joysticks and more)

Posted on

Escape from the Universe - space map design
Escape from the Universe - space map on Nintendo Switch (mockup)
  1. You can now download Castle Game Engine 6.5 “snapshot” (build from the latest GitHub code) from here.

    Until I release a stable Castle Game Engine 6.6, this is the easiest way to test the very latest CGE features (including new GUI editor). I’m working now on making this snapshot fully-automatically updated by Jenkins, and I’ll probably make it linked from our main page soon.

  2. Many editor improvements:

    • Images of TCastleButton are now configurable in the editor.

    • Properties are split into tabs Basic, Layout, Other, All. Note that the Layout tab contains both properties list and anchors UI.

    • Properties TCastleImageControl.Clip, ClipLine, Rotation, RotationCenter are now published and configurable in the editor.

    • You can edit colors in hexadecimal notation, like AABBCC. This allows to easily copy colors between CGE editor and GIMP/Photoshop etc.

    • You can configure TCastleScene animation in the editor (use AutoAnimation, AutoAnimationLoop properties).

  3. TCastleWindowCustom / TCastleControlCustom are renamed to TCastleWindowBase / TCastleControlBase and are simpler to use now, as they by default have a defined background. Control it using the new Container.BackgroundColor and Container.BackgroundEnable properties.

    For new applications, I actually advise using TCastleWindowBase / TCastleControlBase instead of their counterparts TCastleWindow / TCastleControl.

    The downside of using TCastleWindowBase / TCastleControlBase is that you need to add a scene manager instance to them yourself (or using CGE editor). But that’s usually trivial: From code, just do SceneManager := TCastleSceneManager.Create(SomeOwner); Window.Controls.InsertFront(SceneManager);. Or just use CGE editor to add TCastleSceneManager to the appropriate xxx.castle-user-interface design.

    The upside is that you control the moment of creation of the TCastleSceneManager. You don’t have to create it right at the beginning of the application, you don’t have to keep it created until the end of the application. E.g. you can show a main menu, and only create TCastleSceneManager once user presses “Play”. You can even use our TUIState to nicely separate your application into states for this (1 state for “showing the main menu”, 1 state for “playing the game”), and our UI controls play nicely with this (whether you create them in code, or design in CGE editor).

  4. FindFiles is now reliable and cross-platform. Can search recursively in game data (using castle-data:/ protocol) always, even e.g. in Android assets or Nintendo Switch game data.

  5. TGLImage and TGLImageCore are finally merged into one class, TDrawableImage . This makes them simpler.

  6. New class TCastleImagePersistent allows to load images (TDrawableImage) with caching, and can be used to configure image in the editor comfortably. It is used by TCastleImageControl and TCastleButton already.

  7. Joysticks:

    • Refactored (moved a lot of code into platform-specific “backend” classes in separate, internal units).
    • Various API improvements. E.g. you can now just use Joysticks.Count, Joysticks[0].Axis (TVector2).
    • Joysticks work also on Nintendo Switch now.
  8. Introduced static properties TRenderingAttributes.DefaultMinificationFilter, DefaultMagnificationFilter.

    This allows to e.g. easily disable mipmaps in all scenes on some cases, by TRenderingAttributes.DefaultMinificationFilter := minLinear;

Comments on the forum ➤

Castle Game Engine supports Nintendo Switch!

Posted on

Escape from the Universe on Nintendo Switch - design
Escape from the Universe on Nintendo Switch - in CGE editor

Castle Game Engine now supports compiling your games to the Nintendo Switch console ! A modern, succesfull, indie-friendly console from Nintendo.

It is a full integration, really 100% of the engine works on Nintendo Switch. From the developer point of view, you just write cross-platform Pascal code using CGE units, and then you can recompile the application using the Castle Game Engine build tool with --target=nintendo-switch.

Note that the integration code with Nintendo Switch is not public and not open-source. It cannot be, as we are covered by Nintendo NDA agreements and we cannot disclose the technological details about how Nintendo Switch works. To develop on Nintendo Switch, you have to:

  • Become a Nintendo Developer yourself, and sign the necessary NDA agreements between your company and Nintendo. You will most likely want to buy a developer version of the console, as well.
  • Contact me (Michalis Kamburelis) through the non-public Nintendo developer forum. I can then share with you the necessary code that adds Nintendo Switch integration on top of the open-source CGE core, through the Nintendo forum, so Nintendo can confirm it’s legally OK with them. Of course you get this for free. The integration code cannot be open-source, but I still want to give it to everyone for free.

Enjoy a truly cross-platform game engine in Pascal!

Comments on the forum (4) ➤

Android improvements – shadow maps, 64-bit support, upgrades and fixes

Posted on

"Little Things" game on Android'
  • Shadow maps work on OpenGLES (Android and iOS) now!

  • The Android building tools, which are part of our build tool, were updated. We use a new version of Gradle and Android Gradle Plugin under the hood, and by default we compile using Android platform 27. The minimal supported Android version is lower of course — it is 16 (Android 4.1), Android NDK doesn’t support older versions now.

  • You can now build an APK for 64-bit version of Android, which will be required by the Google Play store since August 2019. Use our build tool to compile an APK with both 32-bit and 64-bit variants (for best compatibility): castle-engine package --target=android. Alternatively, you can build a 64-bit-only APK with castle-engine package --os=android --cpu=aarch64. This requires FPC 3.3.1 with Android/Aarch64 cross-compiler.

  • The default project type is now “integrated”, which allows to define various services and also automatically adds OpenAL (sounds), Tremolo (OggVorbis reading), FreeType (font file reading) libraries to your Android project, if they seem necessary (if your data files contain some sound files, .ogg, .ttf etc. files).

  • The latest source code of the Android libraries we use is available in relevant CGE repositories: android-openal, android-tremolo, android-freetype.

  • A couple of bugfixes to Android building were applied. We now use Android NDK platform 16 (for 32-bit builds), not newer, to really work even on Android 4.1. We fixed FreeType usage (so that it works even on older Android devices). And we improved the documentation how to setup your Android SDK/NDK environment.

Comments on the forum ➤

Documentation improvements

Posted on

TCP client/server with Indy and Castle Game Engine

Because people will read again, I improved various parts of our documentation:

Comments on the forum ➤

Sprite Demo from Valter Buccina

Posted on

Sprite Demo

Valter Buccina made a demo application using sprites in Castle Game Engine.

The demo is available on https://github.com/valterb/sprite-demo-castle-engine.

Citing from the README:

Demo is divided into two parts:

  1. Goniometer
  2. Road demo

The first shows with extreme precision the direction of the sprite in degrees. Using mouse click coordinates and Player position we apply the arctangent formula and convert the value obtained in degrees. This way we get the requested direction.

The second one is a demo with a road background where you can move the sprite that is sized according to the distance from the observation point. One click to walk, double click to run. Run animation is divided into three actions, short initial walk, run, short final walk but it is not perfect.

See the forum post for details. (This post was on an old forum — please use new forum for comments.)

Thank you!

Comments on the forum ➤

New rendering capabilities

Posted on

Screenshot of selection at 2019-02-17 22:01:23
Screenshot of selection at 2019-02-17 22:01:41
alpha_channel_override_demo
  • New Appearance.alphaChannel field (TAppearanceNode.AlphaChannel in Pascal) determines alpha channel treatment when rendering a shape with given appearance. We can use alpha testing, alpha blending, or ignore the alpha channel (render as opaque).

    This field overrides the engine auto-detection “how to treat alpha”, which normally looks at Material.trasparent and the alpha channels of textures (which can, in turn, be affected by ImageTexture.alphaChannel). If you set Appearance.alphaChannel to something other than "AUTO" then we avoid any auto-detection, and we just render according to this field.

    This corresponds to glTF alphaMode.

  • New utility methods TCastle2DSceneManager.PositionTo2DWorld and TCastleSceneManager.PositionToWorldPlane have been added, to easily convert mouse/touch position into a position inside 3D/2D game world.

    Our example 2d_dragon_spine_game inside CGE sources demonstrates this, using SceneManager.PositionToWorldPlane to determine target position of the dragon. Also, this example now demonstrates animation blending.

  • glTF texture can be converted to a MovieTexture . If your texture URL is like .avi or .mpg, we will automatically load it as MovieTexture in X3D, and it will actually play in a loop (if you have ffmpeg installed).

Comments on the forum ➤

New user interface capabilities

Posted on

Screenshot of selection at 2019-02-17 18:46:38
Screenshot of selection at 2019-02-17 18:44:53
  • The font rendering behaves better when the text contains a character that we cannot render: it displays a fallback glyph (usually “?”) and makes a warning (using WritelnWarning, so it goes to log). This allows to easily spot missing characters in the font and makes backspace working sensibly if you input a character which glyph isn’t supported.

    You can toggle this by setting TTextureFont.FontData.UseFallbackGlyph to false.

  • TCustomizedFont.Load allows to load font texture in a couple of alternative sizes. The resulting font rendering will look better, it will use the best texture, and thus can look crisp regardless of the final size on screen.

    It is very easy to use this feature by CastleSettings.xml. Simply define a default_font and instead of size_at_load="20" use something like sizes_at_load="10 20 30".

  • TCastleFloatEdit and TCastleIntegerEdit allow to easily edit a Single / Integer value by an edit box.

  • TCastleScrollViewManual allows to have a scrollbar that controls… well, anything you want (handling OnChange event). This is a more flexible version of TCastleScrollView that scrolls user interface inside.

The new controls and font rendering capabilities can be of course easily tested in CGE editor.

Comments on the forum ➤

Using Castle Game Engine with Docker

Posted on

CGE Docker image on Docker hub

We have a Docker image that you can use to easily get Castle Game Engine along with prerequisites (like FPC with various cross-compilers): kambi/castle-engine-cloud-builds-tools image on Docker hub .

If you’re new to Docker, I wrote a nice description how to use Docker with CGE. Basically, instead of installing CGE, FPC, Android SDK/NDK… you can just get a Docker image.

(P.S. Wow, last 2 months were exhausting. I have a ton of news about CGE for you, and will publish them in the upcoming days 🙂 ).

Comments on the forum ➤