Jibble

Author Topic: Play AGS Games via browser  (Read 3757 times)

Re: Play AGS Games via browser
« Reply #20 on: 12 Nov 2020, 18:05 »
Do command line args work in browser version, or it's a non-thing there?

cat

  • Local Moderator
  • AGS Baker
    • cat worked on one or more games that won an AGS Award!
    •  
    • cat worked on one or more games that was nominated for an AGS Award!
Re: Play AGS Games via browser
« Reply #21 on: 12 Nov 2020, 19:04 »
I mostly noticed because I have an in-game option to switch language in two of my games.
I just realised that I can upload multiple files with your link - I also uploaded the translation file and it works  8-0

This is so amazing! Just to understand what you did - you took the engine source code and just used a tool to compile it to web assembly?

eri0o

Re: Play AGS Games via browser
« Reply #22 on: 12 Nov 2020, 19:36 »
Do command line args work in browser version, or it's a non-thing there?

Yes, I can pass command line things there. The game starts "windowed" because I pass the windowed option :)

Calling main and passing parameters has helping functions, but technically any function from the cpp code can be exposed and called and it's possible to pass objects between JS and cpp. The call to main can be seen  here and here. Passing parameters to other functions requires a bit more work but they are doable too.

I mostly noticed because I have an in-game option to switch language in two of my games.
I just realised that I can upload multiple files with your link - I also uploaded the translation file and it works  8-0

This is so amazing! Just to understand what you did - you took the engine source code and just used a tool to compile it to web assembly?

Basically, there are some other minor adjustments but the gist was that. :)
« Last Edit: 12 Nov 2020, 20:25 by eri0o »

Re: Play AGS Games via browser
« Reply #23 on: 12 Nov 2020, 20:29 »
Yes, I can pass command line things there. The game starts "windowed" because I pass the windowed option :)

Calling main and passing parameters has helping functions, but technically any function from the cpp code can be exposed and called and it's possible to pass objects between JS and cpp. The call to main can be seen  here and here. Passing parameters to other functions requires a bit more work but they are doable too.

No, I mean, is it possible to do for end-user (player)?

I guess for better experience it needs some kind of setup overlay though.

eri0o

Re: Play AGS Games via browser
« Reply #24 on: 12 Nov 2020, 20:40 »
Uhm. Then in this case no. I can add my agsconfig thing and use it or just redo winsetup using one of the Engine renderers at some default resolution, then it would run - either with current Engine GUI components or adding ImGui.

Alternatively, I could create a JS/html Gui for editing acsetup.cfg, before running. It's mostly about figuring out what would work best - which I am not sure, but open to any ideas. :) (I think the biggest problem with the JS/HTML GUI is I am not good at it)
« Last Edit: 12 Nov 2020, 22:23 by eri0o »

eri0o

Re: Play AGS Games via browser
« Reply #25 on: 13 Dec 2020, 17:15 »
The MIDI tunes from Oh du lieber Augustin are playing but with incorrect samples.

Hey Creamy, do you have this game somewhere? The download link is not working for me!

arj0n

  • Mittens Vassal
  • art consists in drawing a line somewhere
    • arj0n worked on one or more games that won an AGS Award!
    •  
    • arj0n worked on one or more games that was nominated for an AGS Award!
Re: Play AGS Games via browser
« Reply #26 on: 13 Dec 2020, 18:09 »
@eri0o: archive.org

Monsieur OUXX

  • Mittens Vassal
  • Cavefish
  • Mittens Half Initiate
    • I can help with proof reading
    • I can help with translating
    • I can help with voice acting
    • Monsieur OUXX worked on one or more games that won an AGS Award!
    •  
    • Monsieur OUXX worked on one or more games that was nominated for an AGS Award!
Re: Play AGS Games via browser
« Reply #27 on: 14 Dec 2020, 07:08 »
Can you briefly explain wat we're supposed to see in @eri0o's thing when the upload works? I don't get it. I click upload, I get some debug logging on the right side of the screen, and then nothing. I tried a few games, always the same.


That was some time ago. Today I just tried and it works!!! (Too bad our game cannot actually run on this as it relies on mandatory translation files :/ )
« Last Edit: 14 Dec 2020, 07:15 by Monsieur OUXX »
 

arj0n

  • Mittens Vassal
  • art consists in drawing a line somewhere
    • arj0n worked on one or more games that won an AGS Award!
    •  
    • arj0n worked on one or more games that was nominated for an AGS Award!
Re: Play AGS Games via browser
« Reply #28 on: 14 Dec 2020, 13:19 »
Is OpenGL or DX set as driver for the game mandatory to get it working with https://ericoporto.github.io/agsjs/?
When using Software Renderer as driver it doesn't seem to work:

Code: Adventure Game Studio
  1. 14:16:28:980: Adventure Game Studio v3.5 Interpreter
  2. 14:16:28:986: Copyright (c) 1999-2011 Chris Jones and 2011-2020 others
  3. 14:16:28:986: ACI version 3.5.1.0
  4. 14:16:28:987:
  5. 14:16:28:987: Initializing allegro
  6. 14:16:28:990: Initializing game data
  7. 14:16:28:991: Opened game data file: game28.dta
  8. 14:16:28:992: Game data version: 50
  9. 14:16:28:992: Compiled with: 3.5.0.27
  10. 14:16:28:993: Setting up game configuration
  11. 14:16:28:995: Logging to warnings.log
  12. 14:16:28:995: Data directory: /
  13. 14:16:28:997: Setting up window
  14. 14:16:28:998: Initializing TTF renderer
  15. 14:16:28:999: Initializing mouse: number of buttons reported is 3
  16. 14:16:28:999: Install timer
  17. 14:16:29:056: Opened "Emscripten OpenAL"
  18. 14:16:29:058: Install exit handler
  19. 14:16:29:059: Initialize path finder library
  20. 14:16:29:061: Game GUI version: 119
  21. 14:16:29:063: Requested script API: v3.5.0.7 (7), compat level: v3.5.0.7 (7)
  22. 14:16:29:088: Game title: 'Barahir-8-bit'
  23. 14:16:29:089: Checking for disk space
  24. 14:16:29:090: Game native resolution: 320 x 240 (8 bit)
  25. 14:16:29:091: Graphic settings: driver: OGL, windowed: yes, screen def: scaling, screen size: 0 x 0, match device ratio: ignore, game scale: max_round
  26. 14:16:29:091: Failed to init gfx mode. Error: OpenGL driver does not support 256-color display mode
  27. 14:16:29:092: There was a problem finding and/or creating valid graphics mode for game size 320 x 240 (8-bit) and requested filter 'StdScale'.
  28. 14:16:29:092: (Problem: 'OpenGL driver does not support 256-color display mode')
  29. 14:16:29:093: Try to correct the problem, or seek help from the AGS homepage.

arj0n

  • Mittens Vassal
  • art consists in drawing a line somewhere
    • arj0n worked on one or more games that won an AGS Award!
    •  
    • arj0n worked on one or more games that was nominated for an AGS Award!
Re: Play AGS Games via browser
« Reply #29 on: 14 Dec 2020, 13:19 »
<double post, sorry>

Re: Play AGS Games via browser
« Reply #30 on: 14 Dec 2020, 13:30 »
arjon, it's only OpenGL (or WebGL?), because it runs in browser.
« Last Edit: 14 Dec 2020, 13:32 by Crimson Wizard »

arj0n

  • Mittens Vassal
  • art consists in drawing a line somewhere
    • arj0n worked on one or more games that won an AGS Award!
    •  
    • arj0n worked on one or more games that was nominated for an AGS Award!
Re: Play AGS Games via browser
« Reply #31 on: 14 Dec 2020, 13:54 »
arjon, it's only OpenGL (or WebGL?), because it runs in browser.
Ah, thanx for the clarification.

eri0o

Re: Play AGS Games via browser
« Reply #32 on: 16 Dec 2020, 09:29 »
@Monsieur OUXX, what you mean? Have you tried adding all files in it, including the translation files? What happened? Translation has to be selected by handwriting it in the acsetup.cfg for now.

@arj0n, behind the scenes it uses WebGL, but there are both the OpenGL renderer and the Software renderer ported. I am not familiar with 256 bit games, can you link me one of them so I can try it? Also thanks for the other game. If you want to try to force Software, just write driver = Software (I think that is it at least) in the  acsetup.cfg file and add it toget with your game when uploading and it should work.

There will be soon an update to this JS version of the Engine using a better code with less of my adaptations that will hopefully work better. :)

The idea of the one to push games (launcher) is to test own games, and find bugs, and the single game version would be to release said games (if they work).
« Last Edit: 16 Dec 2020, 09:37 by eri0o »

Snarky

  • Global Moderator
  • Global Moderator
  • Mittens Lord
  • Private Insultant
    • Best Innovation Award Winner 2018, for his numerous additions to the AGS open source ecosystem including the new Awards Ceremony client and modules
    • Snarky worked on one or more games that won an AGS Award!
    •  
    • Snarky worked on one or more games that was nominated for an AGS Award!
Re: Play AGS Games via browser
« Reply #33 on: 16 Dec 2020, 09:35 »
I just wanted to say that this is very cool!

Re: Play AGS Games via browser
« Reply #34 on: 16 Dec 2020, 12:16 »
this is soooo awesome!  8-0 :-*
just tried it with my old AGS2.7.2 game and it works great (Firefox and "Samsung Internet" on Android)
except for MIDI, I can hear something but it is way to slow and completely out of tune  :~(
also the "fade out - fade in" effect I used for room changes seems to just invert the colors before leaving the room
this is the game if you want to try it yourself: Maniac Mansion Mania Episode 53
« Last Edit: 16 Dec 2020, 14:26 by Bòógieman »
>>>> END OF LINE <<<<

eri0o

Re: Play AGS Games via browser
« Reply #35 on: 16 Dec 2020, 14:20 »
@Snarky Thanks!  :-D

@Bòógieman, the fade out and fade in inverted colors is my error, I will fix it. Thanks for spotting it!

I recommend not using MIDI in new games. There are other formats that AGS supports that ship their own soundfonts on the track if tracker format is absolutely desired - next version will have some fixes for modplug tracker too. The midi errors, so far from my tests, appear to be in JS code, I think I will endup modifying Emscripten (the JS libraries part) to use a different backend for midi, but need more testing yet. But it should be possible to fix eventually - just a lot of work.

Re: Play AGS Games via browser
« Reply #36 on: 15 Jan 2021, 08:46 »
Hi @eri0o
This is simply fantastic! I just tried my (work-in-progress) mini-game, I played it for a while and it works perfectly.
I just have one problem with the initial cutscene. It seems like the js version does not wait when the characters are talking, and it just skips to the end of the cutscene.

The code is like that:

Code: Adventure Game Studio
  1. function room_AfterFadeIn()
  2. StartCutscene(eSkipESCOrRightButton);
  3. cBene.SayAt(10, 40, 300, "bla bla bla");
  4. cBene.SayAt(10, 40, 300, "bla bla bla");
  5.  ...
  6. EndCutscene();
  7. mouse.Visible=true;
  8. gIconbar.Visible=true;
  9. gStatusline.Visible=true;
  10. player.ChangeRoom(1, 164, 170);
  11. cBene.ChangeRoom(1, 280, 170);
  12.  

On Windows, it's working: room appears, the character says everything, and then the game opens the main room. But on the JS version, the cutscene room appears for a second, and then the characters go room#1, you don't see her talking. Do you know why? Is there any workaround?
Thanks!

eri0o

Re: Play AGS Games via browser
« Reply #37 on: 15 Jan 2021, 12:23 »
Hi @emabolo!

I have some guesses, I can try to offer a different build of this in the weekend to see if it's fixed. AGS has a bunch of inner game loops that make a bit hard to properly sync the engine and the browser so I use a tool that unrolls this to fake having a single game loop - it mostly works fine though. I wonder if this may be a problem.

Not that long ago, Creamy reported a similar problem with Phylactere module. I am currently working on an Android build of the Engine using the SDL2 port, once it's done, I will start more serious work on this JS/WASM/WebGL port.

About the cutscene may I ask how it's being skipped? I mean, are you actually using Start and End cutscene commands around the cutscene or when you say cutscene you mean just a game dialog? My guess is if it accepts any key, some key is fakely being sent by accident, so if it's the case, I would ask to try to accept only mouse clicks.

@Creamy the MIDI problem has been tracked down, but not sure when a fix will be available - it's in the library in use for playing the sound files for all formats (the good news is the library is still in active development and fixes are being worked on). :/

Spoiler: ShowHide
« Last Edit: 15 Jan 2021, 13:30 by eri0o »

Re: Play AGS Games via browser
« Reply #38 on: 15 Jan 2021, 14:13 »
I tried to comment StartCutscene and EndCutscene and it's the same. The room fades in and fades out, the character doesn't even start talking.

I discovered that the reason is the room has the property ShowPlayerCharacter = FALSE. If I set it to TRUE, everything works normally (apart from the fact that I didn't want the character to appear :)
With False, it seems the code ignores everything and goes to the end.

EDIT: I solved it by setting ShowPlayerCharacter = TRUE, and adding "cEgo.on=0;" inside room_Load(). Now it's perfect!

I hope you will continue working on it, this is a great way to distribute the games, for small ones like mine, probably the best way.
Thanks a lot!
« Last Edit: 15 Jan 2021, 14:32 by emabolo »

eri0o

Re: Play AGS Games via browser
« Reply #39 on: 23 Apr 2021, 20:53 »
Hey, since people really liked this (thanks for the award everyone!) I decided to do a new port.

AGS Web Player (3.6.0 Alpha) ericoporto.github.io/agsjs/3_6_0/index.html

Above is based on code synced with the 3.6.0 Alpha version instead (a comparison here, the repo is github.com/ericoporto/ags/tree/ags3--sdl2--emscripten.

The Software Driver Fullscreen mode is broken but this should not be a problem if your game uses the OGL driver. The software driver is working embedded - there's a lot of change on the fullscreen handling and AFAICT is the only thing that broke (I will eventually fix...) , nevermind, Crimson Wizard fixed it!

As before Alt+Enter toggles fullscreen - same as normal AGS. I will try to revamp the HTML so it's prettier and add some sort of preferences menu, but the idea of this build was to sync to current SDL port that is a bit different on how it was in this version.

building from source note: Building with Emscripten 2.0.16 it works everywhere but has slightly performance issues and has "resting finger bug" (game runs faster when finger is touching the screen), this is the version available above.
Building with latest Emscripten (Tip of Tree), fixes the "resting finger bug" and performance is much improved, but crashes on Chrome Mobile (works everywhere else apparently), so this is why I am not building with the latest version of Emscripten.

notes:
  • this version apparently has a bug that eventually crashes my chrome browser on my phone, but I can't reproduce this on my desktop and the crash on the phone also crashes the chrome debug tools so I can't pickup what's going on :/ It doesn't crash on Firefox mobile so I can't use it's tools instead :( fixed
  • Also, apparently there's some change in the FreeType used by AGS, unfortunate building FreeType to WASM is super hard and I can't figure out, for now I am using a prebuilt FreeType from Emscripten itself, but it's an older version that is different from the one used by AGS and some fonts will render wrong.
  • The game FreakChic is working on this version, the dialog from Phylactere is no longer automatically skipped (previous bug reported by Creamy here).
  • MIDI output is mute in the games I tested, probably need a sound font but using one makes the size huuuge, so I probably won't fix this.
  • resting finger bug, previous version would run slightly faster if the finger was resting on the mobile screen than if wasn't, this one doesn't have this bug. I haven't tracked down why it happened but I think it may be related to the crash on Chrome mobile that is happening in this version. got this bug back
  • why is audio not using multithread?, multithread in JS (pthreads) will require https and some server header configs (coop and coep), I explain a bit here on itch.io, I could not get answer for GitHub pages though. So for now it would be best to make the audio single thread for maximum host compatibility.

There are currently some out of AGS bugs that needs to be fixed. If you try to build the ags js code locally and it doesn't work, it's probably one of these. I applied all fixes for the issues below manually for now.


Because I am using GitHub Pages, the caching is agressive, so if you tried the previous version that crashed on mobile before, you will need to refresh a lot or load with an anonymous session to update to the newer version.
« Last Edit: 26 Apr 2021, 21:46 by eri0o »