Strategy Game Demo using CGE and Tiled

Posted on

Castle Game Engine - strategy game demo - hexagonal Tiled map
Castle Game Engine - strategy game demo - designing menu in CGE Editor
Castle Game Engine - strategy game demo - main menu
Castle Game Engine - strategy game demo - orthogonal Tiled map
Castle Game Engine - strategy game demo - isometric staggered Tiled map
Castle Game Engine - strategy game demo - isometric Tiled map
Strategy game demo - instructions screen, designed using Castle Game Engine Editor
Strategy game demo - humans victory screen, designed using Castle Game Engine Editor
Strategy game demo - aliens victory screen, designed using Castle Game Engine Editor

I’m happy to present a new large Castle Game Engine demo: “Aliens vs Humans”. It is a simple strategy game with maps designed using Tiled.

The demo is in the examples/tiled/strategy_game_demo/ directory of our source code. You can also download precompiled versions for Windows or Linux.

Our Tiled maps API was enhanced with various methods to make writing games easy:

These methods work for all map orientation types (hexagonal, orthogonal, isometric, isometric staggered). This way you can handle e.g. hexagonal and orthogonal maps the same way, with the same code, without worrying about the differences how “neighborhood” is defined differently for hexagons (6 neighbors) and orthogonal maps (4 or 8 neighbors, depending on CornersAreNeighbors).

The user interface is designed using Castle Game Engine Editor. The game code uses TUIState to split the game into states. Each state UI is loaded from a separate .castle-user-interface file. Thus, this is also a demo of how to use TUIState with CGE editor, to organize a larger game into states.

This demo was requested by Castle Game Engine supporters on Patreon. I took some time to make it, as I wanted to make it perfect 🙂 If you’d like to see more crazy CGE demos, join us on Patreon!

Comment on this post ➤

SpriteSheet GUI utility

Posted on

Sprite sheet GUI utlity

A new application to manipulate sprite sheets: https://github.com/valterb/spritesheet-utility , thanks to Valter Buccina!

It is a GUI application for Windows.

You can:

  • Load the necessary images and create the spritesheet.
  • Flip and resize individual images (with or without constraints of proportions). It might be useful for creating spritesheets in the opposite directions.

  • For resizing it is possible to set the interpolation mode in those proposed in TResizeInterpolation.

  • Finally you can load a spritesheet and see the animation. Frame sizes are automatically calculated based on the number of frames and columns. It is possible to change frames per second during the animation.

The application is made using Castle Game Engine, with TCastleImage, TGLImage, TCastleControl and TSprite.

See the related forum thread.

Comment on this post ➤

Swappy Jigsaw – Puzzle Game using Castle Game Engine

Posted on

Swappy Jigsaw Screenshot

With big thanks to Eugene Loza, we can celebrate new year with a new game using Castle Game Engine!

Swappy Jigsaw is a simple jigsaw puzzle game, where you have to unravel an image split into many tiles. Click to pick a tile and click another tile to swap them. There are 84 images total. The game is made in Castle Game Engine (Lazarus/FreePascal), is free, libre and open source.

Comment on this post ➤

Tiled Maps improvements

Posted on

tiled4
tiled10
tiled9
tiled5
tiled6
tiled1
tiled2
tiled7
tiled8

Many new features in our integration with Tiled, a cool open-source 2D map editor. They all can be tested by the examples/tiled/map_viewer application from the Castle Game Engine sources on GitHub.

This work is sponsored by supporters of Castle Game Engine on Patreon. You asked for a Tiled demo, it is in progress now:) Thank you for supporting the engine!

Tiled integration improvements:

  • Support Isometric, Isometric Staggered, Hexagonal maps (in addition to simple Orthogonal).

  • New properties: URL (easily load/unload the map), Origin, Scale (easily move and zoom the map), SmoothScaling, SmoothScalingSafeBorder (adjust map scaling mode). See the API documentation of TCastleTiledMapControl.

  • TCastleTiledMapControl is nicely configurable in the CGE Editor.

  • Tiled demo (in examples/tiled/map_viewer) improved a lot, designed using CGE Editor, and allows to move and scale the map, as well as adjust scaling properties.

  • Fix reading some Tiled files (support offset as float, try harder to determine proper tile size).

  • Use BackgroundColor optionally set in Tiled.

  • TCastleTiledMapControl is correctly influenced by UI scaling and anchors.

  • Refactored some internal structures.

Comment on this post ➤

Database-aware demo using Castle Game Engine UI

Posted on

db_cge_1
db_no_cge
db_cge_2

You asked on Patreon can we have database-aware controls in CGE UI. Of course! 🙂

I present a simple implementation of a database-aware edit box using Castle Game Engine user interface. The repository https://github.com/castle-engine/castle-db-aware-controls contains an implementation and demo of TCastleDBEdit. It is a database-aware edit box (analogous to standard LCL TDBEdit), that is rendered using Castle Game Engine. It can be added to your window using CGE Editor.

As a database-aware control, it can be trivially connected to display or edit a database entry. More precisely: anything that descends from TDataSet, which includes a variety of SQL databases, or simple tables using DBF, CSV files and so on.

The example application also shows that you can use a TDataModule (where you drop and edit components using Lazarus) together with CGE user interface.

The application depends on the latest Castle Game Engine 6.5 from GitHub.

If you’d like to help in the development of the engine, and be able to request features like that, please support our development on Patreon. Thank you! And Merry Christmas! 🙂

Comment on this post ➤

glTF 2.0 in Castle Game Engine

Posted on

BrainStem_0
Duck_0
Sponza_0
Sponza_1
gltf_fish
gBoomBoxWithAxes_0

Castle Game Engine and view3dscene can now open glTF 2.0 model format. glTF is an efficient, modern 3D model format developed by Khronos.

Basic features of glTF are supported for now:

  • hierarchy of transformations,
  • meshes (with various primitive modes allowed, with Appearance nodes shared as much as possible),
  • materials (but without PBR for now; we just use glTF baseColor as Phong diffuseColor now),
  • textures (baseColorTexture and normalTexture, with configurable texture wrapping and filtering, with multiple texture coordinates on the same mesh possible),
  • cameras (orthographic or perspective),
  • miscellaneous (alpha mode (using CGE existing alphaChannel extension), double-sidedness, textures embedded in GLB buffers).

You can open glTF directly (using view3dscen “File->Open”), or you can use Inline X3D node to add glTF model to a larger X3D scene. You can also convert glTF to X3D (just open it in view3dscene, and then use one of “File->Save As…” menu entries to save in classic or XML encoding). You can also convert from the command-line, see view3dscene docs.

You can use view3dscene from snapshots or Castle Game Engine from GitHub to try it all today! If you’re looking for sample models, see glTF sample models . Or just export something from Blender 🙂

We use PasGLTF, a great open-source library for reading glTF by Benjamin “Bero” Rosseaux. It supports both GLTF (text JSON file accompanied by binary files) and GLB (everything packed in one binary file) formats. I encourage you to support Benjamin Rosseaux on Patreon to show the appreciation!

Comment on this post ➤

November Engine Features (Part 5): Sprites (example and tool to create sprite sheets), examine camera improvements

Posted on

Character from "The Unholy Society" ( unholy-society.com ) remade as a sprite sheet
sprite_sheet_animation example, using character from "The Unholy Society" ( unholy-society.com ) (remade as sprite sheet)
  1. A new example how to render sprites using the TSprite class was added: look in the examples/sprite_sheets/sprite_sheet_animation directory.

    Also, a simple tool to create a sprite sheet from a sequence of images is now available in the examples/sprite_sheets/combine_images_into_sprite_sheet directory.

  2. New features of TExamineCamera:

    1. Disable rotations by RotationEnabled

    2. Configure mouse buttons by MouseButtonRotate, MouseButtonMove, MouseButtonZoom.

    3. Zooming works with orthogonal camera (in which case we need to scale the model, as moving camera closer/further away doesn’t have any visible effect).

  3. LogFileName allows to easily configure log destination.

Comment on this post ➤

November Engine Features (Part 4): CastleSettings.xml, DPI scaling, cleaner component palette

Posted on

Castle Game Engine Editor - design with checkboxes, labels, edit boxes
  1. You can create a file called CastleSettings.xml to define some UI properties, like UI scaling and default font. This file allows your game and CGE editor to use the same settings (e.g. same default font). In your game just call Window.Container.LoadSettings('castle-data:/CastleSettings.xml'); to load these settings.

  2. DPI scaling is now better.

    TCastleWindowCustom.Dpi and TUIContainer.Dpi (“dots per inch”, aka “pixels per inch”) is now correct in all situations, on all backends. This includes GTK, WinAPI, X11 and LCL backends (in addition to the previous Android and iOS). It is also now valid for TCastleControl.

    Note that in some cases (desktops), this property is configurable by user, and actually means “a user preference how should the user interface be scaled”. Only in some cases (on mobile devices) it actually reflects the physical dimensions of the screen (pixels per physical inch).

    Moreover, you have a new option to scale user interface: usDpiScale. This is great for desktop applications. It follows the auto-scaling of Lazarus LCL applications.

  3. The “Castle” component palette in Lazarus is now much cleaner.

    It now contains only visual components that make most sense to be dropped on a Lazarus form: TCastleControl, TCastle2DControl, TCastleControlCustom. Plus non-visual dialog components.

    Previously, it contained a lot of other CGE components, that were not visualized at design-time in Lazarus. Having them on a component palette was probably more confusing than useful — e.g. you could drop TCastleButton on a Lazarus form, but (surprisingly) it’s a non-visual component for Lazarus (as far as Lazarus LCL is concerned, because it’s actually rendered using OpenGL in CGE).

    The new CGE editor is a solution to visually edit CGE user interface components, like TCastleButton.

    If you need backward compatibility, simply add {$I CASTLE_REGISTER_ALL_COMPONENTS_IN_LAZARUS} to the src/castleconf.inc. Reinstall the CGE packages, and the components will appear back. But please note that this is a temporary workaround: In the future, you should either instantiate them by code, or design them using CGE editor and load as `UserInterfaceLoad(‘xxx.castle-user-interface’)`.

Comment on this post ➤

November Engine Features (Part 3): User interface classes (checkbox, refer to embedded design, …)

Posted on

Castle Game Engine play_animation demo
Castle Game Engine Editor - design with checkboxes, labels, edit boxes

New and improved user interface controls:

  1. New TCastleCheckbox shows a standard checkbox with a caption. It supports the standard properties and events, like Checked, Caption, OnChange and so on.

    I also recommend TCastleCheckbox implementation as a demo of implementing a component by composing some other internal components. In this case, TCastleCheckbox is realized as 2x TCastleImageControl and TCastleLabel instances. This is much easier and more powerful than drawing everything in the component Render method yourself.

  2. A new UI control TCastleDesign allows to reference a xxx.castle-user-interface file. This is especially useful inside the editor, to visually see one xxx.castle-user-interface file embedded inside another yyy.castle-user-interface.

    From code, it is usually more straightforward to load designs using UserInterfaceLoad global function, than to use TCastleDesign.

  3. TCastleLabel is now by default black. This makes it consistent with other UI controls (that generally assume “dark text over light background”), and avoids a confusion when default TCastleLabel isn’t visible over default TCastleRectangleColor (as they were both pure white, in previous engine version).

    On a related note, TCastleSceneManager no longer has pure black background, it has very dark gray (0.1, 0.1, 0.1, 1) background. This way pure black things are clearly visible over it. See Upgrading to Castle Game Engine 6.6 for detailed reasoning.

  4. TCastleScrollView received a number of fixes.

  5. TCastleVerticalGroup and TCastleHorizontalGroup have now configurable AutoSize and by default zero Padding and Spacing (more intuitive).

  6. You can now activate TCastleImageControl.DetectScaleFromUrl. This affects how the auto-scaling works, and detects special filenames like [email protected]. If you load an image file called [email protected] with size 20×20, and set DetectScaleFromUrl to true, then the automatically calculated control size will be 10×10 (2x smaller than the actual image size).

    This is a very useful trick to provide “upscaled” images that work with any UI scaling.

  7. TCastleButton.CustomColorXxx allows to configure button look by a solid color.

  8. The TCastleEdit has a number of new features:

    1. Placeholder text with PlaceholderColor
    2. PasswordChar to present password-input fields,
    3. OnChange event, AutoSize property.
Comment on this post ➤