Big progress of web target and 10 new demos ready to play in your web browser

Posted on

Web demo play_animation
Web demo of IFC format support
Web demo platformer
Web demo platformer
Web demo platformer, fullscreen, with Vivaldi (based on Chromium) console
Web demo platformer, fullscreen, with Vivaldi (based on Chromium) console
Web demo space_shooter
Web demo zombie_fighter
Web demo strategy game using Tiled
Web demo strategy game using Tiled
Web demo - components gallery
Web demo - console stuff

We proudly present next milestone of our web target! The goal is simple: recompile any application developed using Castle Game Engine and FPC to run in a web browser. Any modern web browser (FireFox or Chrome, desktop or mobile) is good.

Before we go into technical details, we have added 10 new demos to try out:

2D demos:

3D demos:

New features of the web target:

  • We fully support application data. You can provide designs, 3D models, images, and any other arbitary data to your games.

    Internally, we package the application data to zip, then download it in a pas2js application, then use it in the WebAssembly application.

    The details why ZIP is suitable for this are in How it works section of our web docs, that describes a lot of details for people interested what goes on “under the hood”.

    This feature is accompanied with new TCastleZip class in our engine. It is used internally by the web target and build tool, but it’s also exposed to you — for any custom purposes you have in your games. It can handle ZIP files (reading and writing) in a cross-platform way, with both compilers we support (FPC and Delphi), with support for URLs throughout the API (as it normal for our engine). It includes the ability to easily register ZIP as a “URL protocol handler for our engine”. The basic examples are in the TCastleZip API docs and a complete example is in new examples/network/custom_url_handler.

    We have more plans about this ZIP usage. It can be used to provide encryption in data. It can be used to simplify passing data through Delphi’s PA Server. Stay tuned for more development.

  • We optimized image loading on the web.

  • Adjusted default canvas size.

  • We can switch to Fullscreen mode on the web. Our index.html already features a button to do this on any example.

    Note that it’s also available in mobile platforms, switching to fullscreen on mobile allows to use all available phone/tablet screen space, and it adjusts to the portrait/landscape mode.

  • Fixed rendering to be “crisp” (fixes old issues with “fuzzy fonts”). This actually needed 2 fixes:

    • We need premultipliedAlpha=false. See comments.

    • We need to adjust canvas size to match display size in pixels. This was quite hard to do exactly right, fortunately others encountered and documented this too and we could follow in their footsteps. See docs and explanations about devicePixelRatio and resizing canvas: WebGL fundamentals, Khronos Wiki.

  • TCastleApplicationProperties.ShowUserInterfaceToQuit is false on web.

  • Improved our mechanism to “counter the cache” when running web applications.

  • Improvements to specific examples:

    • platformer: Allow shooting with Enter.
    • space_shooter: Added explosions. Allow “arming the missiles” by holding “e”.
    • ifc: Switch whether mouse left button does selection or navigation. (Right mouse button does the other action.) Usage of the right mouse button is not good for web — browsers use right mouse button for the context menu, so it conflicts, and you get unwanted context menu when trying to do something else. It seems we could disable context menu in some cases, and we’ll look into it, but for mobile sake (when the right mouse button is not available at all — whether it is native mobie app, or web app opened on phone) applications should just enable all functionality only with left mouse button.

Aaand that’s not everything we did in February. More news will come 🙂

If you like what we do, please remember we count on your support on Patreon and other forms of donations. Have fun making games!

Start the discussion at Castle Game Engine Forum