AGS engine Web port

Started by eri0o, Wed 26/05/2021 02:45:17

Previous topic - Next topic

newwaveburritos

When I use the link from your website (https://ericoporto.github.io/agsjs/) it doesn't work and the console tells me this:

Failed to load resource: the server responded with a status of 404 ()
(index):1 00:03:49:504: Adventure Game Studio v3.6 Interpreter
(index):1 00:03:49:509: Copyright (c) 1999-2011 Chris Jones and 2011-2022 others
(index):1 00:03:49:509: ACI version 3.6.0.24
(index):1 00:03:49:510:
(index):1 00:03:49:510: Initializing backend libs
(index):1 00:03:49:511: Initializing game data
(index):1 00:03:49:513: Opened game data file: game28.dta
(index):1 00:03:49:513: Game data version: 3060021
(index):1 00:03:49:513: Compiled with: 3.6.0.35
(index):1 00:03:49:513: Startup directory: /
(index):1 00:03:49:513: Data directory: /
(index):1 00:03:49:513: Setting up game configuration
(index):1 00:03:49:516: Logging to warnings.log
(index):1 00:03:49:518: Unable to init voice pack 'speech.vox', file not found or of unknown format.
(index):1 00:03:49:519: Initializing TTF renderer
(index):1 00:03:49:519: Initializing mouse: number of buttons reported is 3
(index):1 00:03:49:519: Install timer
(index):1 00:03:49:519: Audio driver: emscripten
(index):1 00:03:49:533: AudioCore: opened device "Emscripten OpenAL"
(index):1 00:03:49:533:
(index):1 00:03:49:537: Install exit handler
(index):1 00:03:49:537: Initialize path finder library
(index):1 00:03:49:539: Game title: 'Saturday Night Jam'
(index):1 00:03:49:551: Game GUI version: 119
(index):1 00:03:49:555: Requested script API: unknown (3060026), compat level: unknown (3060026)
(index):1 00:03:49:555: Warning: this game requests a higher version of AGS script API, it may not run correctly or run at all.
(index):1 00:03:49:594: unresolved import 'Overlay::CreateGraphical^5' in 'SpeechBubble_0.8.0.asc'
(index):1 00:03:49:594: unresolved import 'Character::Animate^7' in 'SpeechBubble_0.8.0.asc'
(index):1 00:03:49:595: Loading game failed with error:
(index):1 00:03:49:595: Script link failed.
(index):1 00:03:49:595: Error (line unknown): in SpeechBubble_0.8.0.asc: 2 unresolved imports (last: Character::Animate^7).
(index):1 00:03:49:595:
(index):1 00:03:49:595: The game files may be incomplete, corrupt or from unsupported version of AGS.
(index):1 00:03:49:599: ***** ENGINE HAS SHUTDOWN

It does work when I upload to itch.io so it's sort of immaterial really but I thought you might want to know about it.  I commented out some other code that also wasn't working that was telling me I had some unresolved imports of GUI buttons which is what led me here.  It's weird though because I had both of those pieces of code in it before and I did manage to make it work.  I was so excited I took a screenshot so I know I wasn't dreaming!!

eri0o

#41
I haven't updated the code in my website for some time, trust the one that comes with the AGS Editor! :)

Btw, if you want have the same behavior locally, just delete that very small js file that lists your game files. If you run the index.html locally, it will now ask for you to place your game files.

Edit: Just updated the website!

eri0o

https://github.com/GimmickNG/agsjs-bundler

More a note to myself, but someone in GitHub created an interesting bundler for ags web port that has two interesting features

  • serving the web port, for local testing
  • zipping the directory, for uploading in websites

I think these are interesting things to keep in mind to add in the Editor at some point - probably zipping is a thing for the future after we migrate building to integrated command line tools.

jumpjack

#43
I see that in the WEB folder two .ags files are created: one is the copy of the .ags game, named as I called my game (for example pacman.ags), the other has the "standard" name my_ags_game.ags . Why are both needed? They differ only by 1KB, but it looks like a waste of space..

eri0o

There's no standard name, if there's an extra .AGS file in the directory either you put there or you put in the Data directory.

jumpjack

Quote from: eri0o on Thu 12/01/2023 08:41:39There's no standard name, if there's an extra .AGS file in the directory either you put there or you put in the Data directory.
I didn't do anything manually, all files have been created by AGS. I also tried deleting all of them, but upon compiling it recreates both .ags files.

eri0o

There's no such file from AGS Editor.

Either you placed files manually in the Editor directories, which I would recommend uninstalling/deleting your editor and getting a new one.

Or you added a file in Compiled/Data dir, any file that is added in Data dir is copied to all targets - there may be exceptions.

Or you are not using the Editor at all and is using something else. The way to build is to mark the platform in general settings and hit f7.

jumpjack

it's even listed in my_game_files.js , and I didn't create it!

https://github.com/jumpjack/Space1999Adventure/blob/main/AGSdebug2/my_game_files.js

I am using 3.6.0 RC4.

jumpjack

I have another installation of AGS 3.6.0 RC4 in another PC (but reading/writing the game in same cloud folder of the other PC), and it does not create the "phantom" my_ags_game.ags , so I don't know what is going on.
In  the AGS-3.6.0.39-RC4.zip file there is no my_ags_game.ags file.
I started with 3.6.0 RC3 but I see it is no more downloadable so I cannot check.

I see that if I put a .ags file in data folder, upon compiling it's copied to web fodler and added to the list of files in my_game_files.js. But why should I add a .ags file in data folder? And can a game be made of multiple .ags files?

eri0o

#49
So, yes, you can make a game of AGS games, you do so using the RunAGSgame command.

https://adventuregamestudio.github.io/ags-manual/Globalfunctions_General.html#runagsgame

I advise against though, unless really needed - say you got together with a bunch of people, each one made a game, and are looking into making a launcher for all games. Or you are making an episodic game and want to make a launcher for each episode. There are other usecases but other than this it is usually not very good idea - there isn't good ways to integrate AGS games.

Now, about Data dir, nowadays AGS can package arbitrary files (in general settings, there is an option in the Compiler section if I am not mistaken) and you can read them later by leveraging the $DATA$ token: https://adventuregamestudio.github.io/ags-manual/File.html#fileopen . Also this data token matching the other data I am going to explain later is just we are bad at naming things problem.

But before this, if someone wanted to send an arbitrary file (say you have a descriptor file for puzzle levels or some other config file you want to have in the same directory of the game or even just a readme), it had to be in the same directory as the game, externally.

So to ease debugging, testing and packaging of games using such approach, the way it works is any file that is not the own game .AGS file that is place in the Compiled/Data directory is then copied to all other Compiled/Windows, Compiled/Linux and so on. At some point before the Compiled/Data was also a different directory (I think in 3.4.1 and before), just the top level, so perhaps it made more sense then.

Any free files in the webport have to be in the same directory as the game, because in the simulated filesystem we have there , there are no directories. You can have "directories" inside AGS packages using the arbitrary file packaging. (But it's read only)

Manu

I have a problem publishing the compiled web version on itch.io. I compiled the game with AGS 3.6.0.41. I zipped the Web folder and uploaded it to my page. The problem is the game is 320x200, but if I set the size 320x200 on itch.io, the game runs in a tiny rectangle in the middle of the page. If I set the size 640x400 on itch, the rectangle is bigger, but the game runs in the center of the rectangle, still at 320x200. How do I set the game so that it scales up?
Thanks a lot!

eri0o

#51
@Manu , there isn't anything much, if the game is not fullscreen, it should follow your windowed game configurations. Can you share me your acsetup.cfg? (specifically the one uploaded in the zip file)

Here is an example config in itch.io itself
Spoiler
[close]

Here is the game from this config (the password is: webtest)

https://eri0o.itch.io/agsjs-test




The acsetup.cfg (I can't use spoilers in code in the forums or the code misses the line ends for some reason)
Code: ini
[misc]
game_width=320
game_height=200
gamecolordepth=32
antialias=0
cachemax=131072
user_data_dir=
shared_data_dir=
titletext=TestWeb Setup
show_fps=0
[graphics]
driver=D3D9
windowed=0
fullscreen=desktop
window=desktop
game_scale_fs=proportional
game_scale_win=round
filter=stdscale
vsync=0
render_at_screenres=0
rotation=0
[sound]
enabled=1
driver=
usespeech=1
[language]
translation=
[mouse]
auto_lock=0
speed=1
[touch]
emulate_mouse=1

Manu

Ok, I fixed it with:

Code: ags
windowed=0
fullscreen=desktop
window=desktop
game_scale_fs=proportional
game_scale_win=round

and setting the viewport to 640x400.

Previously the game was windowed and game_scale_win was 3.
Thanks a lot!

eri0o

@Manu , good thing it worked out! Send a link to the game later so I can play  :-D

Manu

I have another problem. I'm not sure if it's me or if it's a known limitation of the web engine, but the game does not play the OGV video I added.

The video is played with:
Code: ags
  PlayVideo("video/star1.ogv", eVideoSkipAnyKeyOrMouse, 1);

I added the file star1.ogv to the zip file (I tried both in a "video" folder and at the same level as the .ags file.
I added star1.ogv at the end of the array in my_game_files.js like this:
Code: ags
var gamefiles = ['audio.vox', 'speech.vox', 'game.ags', 'acsetup.cfg','video/star1.ogv'];

or

var gamefiles = ['audio.vox', 'speech.vox', 'game.ags', 'acsetup.cfg','star1.ogv'];

In both cases, it doesn't work. The game ignores the video
Are OGV videos supposed to work with the web engine?




Crimson Wizard

OGV should work anywhere, so that's a question of whether a file is found or not.

If I remember right, web port does not support subfolders yet, so you need to place everything in the same dir. The PlayVideo command of course also should not have subfolders in filename.

Alternatively, you may place the video files in the project root folder and compile the game, then the Editor will package them inside the *.ags file automatically.

Manu

Ahh, you are right! I just needed to move the *.ogv to the main folder. Now the video is included in the *.ags file, and the web version works without problems. The only thing to do to play it on itch is to zip the Web folder and upload it.

Great job with this port!


eri0o

Thank you! If a game is mobile friendly you can mark so in itch.io, for the game in question it isn't since it needs a keyboard. Make sure you didn't check this accidentally - usually itch notifies if it detects someone is using a phone and trying to play a non-mobile friendly game, but for your game it didn't.

Manu

Quote from: eri0o on Sat 21/01/2023 20:34:34Thank you! If a game is mobile friendly you can mark so in itch.io, for the game in question it isn't since it needs a keyboard.

I didn't mark the game as mobile friendly; in fact, when I open the page on my iPhone, it says: "This game is not designed to run on your device". Don't you see this warning?

By the way, I have a half-idea about how to make the game playable on mobile/without a keyboard, but it will require some work.

SMF spam blocked by CleanTalk