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!

Comment on this post ➤

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).

Comment on this post ➤

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.

Comment on this post ➤

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 🙂 ).

Comment on this post ➤

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 ➤