Excerpts from WEB-build and Itch.io deploy of CGE Project journey

Following the topic of my game Tower Fight, Samurai Arcade for testing math Skills - #4 by michalis

and stealing a good topic naming from topic Excerpts from the Shooter development journey :) - #14 by hal09

Here what I have to say. First about the hard parts, the next post in this topic - for requests on WEB platform.

  1. Do not use MessageYesNo and probably all other dialogs/dialog functions from CastleMessages unit, they contain Blocking of app flow with Application.ProcessMessages, also don’t use ProcessMessages itself, it hangs the Web-page, you even have troubles to close the page. I was using it for sample questions to the user, but had to switch to my custom view-based dialog approach: Remade messagedialog to custom one · phomm/Towerfight@cf6f623 · GitHub
  2. Do not use Keyboard key like Escape, Space, Tab, PgUp, PgDn, maybe even arrow keys, they switch the focus of html-canvas or scroll the page, which makes playing uncomfortable, I knew about Escape, but others I had myself to bump into :sweat_smile:, for example I added a Backspace to duplicate “exiting” function, which on desktop is done by Escape
  3. Use ApplicationProperties.ShowUserInterfaceToQuit from CastleApplicationProperties unit everywhere you can to hide various controls, it make sense not only on mobile, but web as well, I use it to disable Exit button and corresponding controls, also Fullscreen selector, as on Web it is controlled outside: by canvas.requestFullScreen if you use castle standard html-template, or by Itch special fullscreen button, if you post game to itch.
  4. I have a thing that bothers me on Android build, you need to disable orientation-lock to be able to rotate cge-window to landscape. But if you post the game to itch , there is a setting to setup landscape-always, which works even in mobile browser and you don’t need to disable lock.
  5. The standard html-template of cge-web project is not compatible with itch (iframe shows only part of canvas, and in itch-fullscreen-mode the button from castle html template for fullscreen isn’t working), I had to adjust the template, I think @michalis would add such a template as an option. The changes you need - remove the style attribute from canvas element, comment/remove all other elements (button and hrefs), except canvas, bc they could capture the focus from canvas and break the gameplay. Itch kinda requires bare canvas for 100% of iframe and controls fullscreen by its own mechanism and button. for this you need CSS (separate or embedded into style attribute) :
  6. #castle-canvas {
    position:fixed;
    left:0;
    top:0;
    width:100%;
    height:100%;
    }
2 Likes

What I wanted to discuss/request for web platform :slight_smile:

obviously I wait WebAudio :sweat_smile: as a game without it is really different as designed

Also would be nice to have UserConfig flow to store basic settings in user’s storage in browser

My personal (maybe not so important for other devs) is TCastleDownload, because one of soon to be implemented features for the web-game is leaderboard based on server and requests from game-app

As a lazy programmer, I’m always down for automations and really love CI templates provided by Castle to automatically build and publish artifacts to castle releases, and I use this feature for both my games. And even more - I have a custom step in pipeline to upload artifact to google drive. So AFAIK, Itch supports automation, and uploading new build is doable thru the pipeline, which I would love to have. But as I know it is not yet fully prepared in CI template (as requires updating docker image with crossfpc and pas2js). Would be cool to have it eventually.

Those are my expectations/favorites :sweat_smile: Let’s maybe discuss :slight_smile:

From my side - I’m not a JS developer (i’m a .net backend), however I have some experience with JS, and I think with the help of AI something could be achieved. Or , for example the Docker part seems doable to me, as I work with docker from time to time, and also building fpc stuff from sources sometimes.

1 Like

Indeed, on web Application.ProcessMessages will not work, and routines relying on it, like MessageYesNo will also fail.

This is the same situation as with iOS known problems.

Note that you can still use our dialogs, by using views:

  • You can use unit CastleDialogViews (which define views, which are the underlying things inside MessageXxx) and create related views yourself. Like this:
var
  Dlg: TViewDialogOK;
begin
  // open new view with dialog
  Dlg := TViewDialogOK.Create(Self);
  Dlg.Caption := 'Some content to display';
  Container.PushView(Dlg);
end;

This is what e.g. castle-model-viewer-mobile uses, and it works on iOS and web too.

  • You can set MessageOKPushesView to actually make MessageOK(...) do something like above. But naturally it cannot work for routines like MessagesYesNo, so my simpler advise for iOS and web is just to not use CastleMessages unit at all, and not use MessageXxx at all.

Basically, I confirm your advise :slight_smile: I will update known limitations section in “web” docs shortly.

Indeed, browsers capture various keys for their purpose. Our control still receives (some) of them, but the UX is bad when both our game and the browser do some action on these keys.

As above: I will update known limitations section in “web” docs shortly.

Also confirmed :slight_smile: ShowUserInterfaceToQuit is false on web and one should honor it, by not showing the UX (buttons etc.) to user to “Quit” the application, since on web → there’s no quit, users just close their tab / browser window etc.

Hm, you mean in a web browser on Android? There is a way to request that full-screen is forced to landscape? Thank you – added to TODO, we should find it and use too. We could then make screen_orientation from manifest work on web too, so using screen_orientation="landscape" would work on the web.

Thank you – we should indeed introduce some way to provide custom templates, and maybe just provide a ready template to do out-of-the-box something proper for itch.io as you show.

Your post is a great reference for people who want to upload their web games on itch.io, thank you!

I have 2 of above, WebAudio and a TCastleDownload-web backend already in progress :slight_smile:

They work – but WebAudio needs review (parts of it have been generated by Claude Code) and TCastleDownload-web needs rework to be cleaner (here also Claude Code helped, but what it did must be now fixed). You will like our next update :), hopefully this weekend.

Indeed, exactly as you say. Itch.io has butler to upload builds from the command-line (so also from any automated work, CI/CD). We use it e.g. to upload platformer to itch.io.

As you say, to use this from CI/CD, we miss easy way to get all web prerequisites (FPC cross-compiler for WebAssembly, pas2js) in a CI runner (ideally, both in our Docker image and in through our castle-build-ci scripts ).

I want to solve it by zipping the prerequisites in castle-fpc releases. Then the “web prerequisites” could be:

  • placed in Docker image,
  • downloaded by castle-build-ci scripts,
  • but also downloaded easily by CGE editor, so that building for web is just “a simple button press from our editor”.

I agree 100% with all your feature requests. I think they actually match perfectly the things I see as “most priority” for web! :slight_smile: So, this makes me happy, we’re going in a good direction.

2 Likes

Looks like JS ScreenOrientation.lock is the key to do this. Mentioned also here (Managing screen orientation). Added to TODO in our web docs.

1 Like

This is my observation. I configured the game config panel (on itch) , among others there is a selector for Forced landscape mode. When I opened the game on Android inside browser in fullscreen mode (via itch fullscreen button), it preserves landscape despite phone setting to enable/disable rotation of orientation.

Great ! Lovely ! I will proceed with my features so maybe even in sync with cge updates :sweat_smile:

1 Like

Done. I added to “Known Limitations” on web notes about Application.ProcessMessage, CastleMessages, keys, and ShowUserInterfaceToQuit.

1 Like