News:

Herr Otto Partz says you're all nothing but pipsqueaks!

Main Menu

Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets

Started by HunterBoy344, June 24, 2022, 01:16:59 AM

Previous topic - Next topic

HunterBoy344

I had an idea recently to make a multiplayer system for Stunts in the browser. The game itself would be run using em-dosbox, and replay files would be used to make a live leaderboard for a specific track chosen by the server and distributed to clients. The track would rotate every 5 minutes, and whatever user had the best time at the end of that would win the round.

Today I started making it! The biggest challenge thus far has been getting Stunts to work properly in the browser, but as of right now it seems to be working okay. I'm trying to figure out how I can add a custom config file to em-dosbox (for better framerate and possibly sound) but at least at the moment the game runs.

Here is a link to try it out! I haven't added any multiplayer features yet, but the website does load the game. I'll post development updates here as they happen!
https://stuntsthing.hunterboy344.repl.co (URL has been changed, see below)
https://StuntsOnline.hunterboy344.repl.co

HunterBoy344

Development update: The game now runs at full FPS! I figured out how to set up a custom DOSBox config for em-dosbox, though I still unfortunately can't get sound working. My next priority will be to get some actual multiplayer functionality working. Wish me luck!

And yes, if you were wondering, the changes I've made thus far are live on the website.

Cas

It does work!  On my computer and browser, it gets to about 4 to 5 frames per second, but it does work. Interestingly, it doesn't skip frames. It just goes slower, which allows for a lot of control.
Earth is my country. Science is my religion.

Daniel3D

On my computer DosBox starts but no drive is mounted so there is no stunts.
I did notice the copy protections hints. We have alternative executables that don't have the copy protection anymore.

But i really like this idea. There are definitely uses for it.
Edison once said,
"I have not failed 10,000 times,
I've successfully found 10,000 ways that will not work."
---------
Currently running over 20 separate instances of Stunts
---------
Check out the STUNTS resources on my Mega (globe icon)

Daniel3D

Quote from: Cas on June 24, 2022, 06:52:51 AM
It does work!  On my computer and browser, it gets to about 4 to 5 frames per second, but it does work. Interestingly, it doesn't skip frames. It just goes slower, which allows for a lot of control.
Tried again, now it works for me too. But also slower. Exactly at half speed. (I timed it with a stopwatch).
I have no sound and because the speed is so slow my reflexes are off. So very difficult to drive.
Although, if you get used to it, then a slower running game could give you an advantage.

I'm no expert in the technical website stuff. But is the game loaded in memory of the local computer or on the web server?
That would have a lot of impact on the performance.
Edison once said,
"I have not failed 10,000 times,
I've successfully found 10,000 ways that will not work."
---------
Currently running over 20 separate instances of Stunts
---------
Check out the STUNTS resources on my Mega (globe icon)

HunterBoy344

Quote from: Cas on June 24, 2022, 06:52:51 AM
It does work!  On my computer and browser, it gets to about 4 to 5 frames per second, but it does work. Interestingly, it doesn't skip frames. It just goes slower, which allows for a lot of control.

That's odd... it runs at full speed on my end. Maybe I set the CPU cycles too high? It's set to 20000 right now. Try running the game and tell me what the title of the tab says; the tab label lists the current CPU cycles among other things.

Quote from: Daniel3D on June 24, 2022, 09:53:30 AM
I'm no expert in the technical website stuff. But is the game loaded in memory of the local computer or on the web server?
That would have a lot of impact on the performance.

The game is run locally in the browser using em-dosbox, meaning that the game is run using the local computer's resources. This does mean performance varies based on the device running the game.

I'll try tweaking the DOSBox settings to see if that does anything.

Cas

Uhm... something strange happens now. I open the page and DOSBOX displays Z:\>   I wait, but it doesn't automatically load Stunts, so I try to enter C: to then look for Stunts there, but... it's not taking my Shift key, so when I try to type a colon, I get a semicolon instead.
Earth is my country. Science is my religion.

Daniel3D

Quote from: Cas on June 24, 2022, 08:17:22 PM
Uhm... something strange happens now. I open the page and DOSBOX displays Z:\>   I wait, but it doesn't automatically load Stunts, so I try to enter C: to then look for Stunts there, but... it's not taking my Shift key, so when I try to type a colon, I get a semicolon instead.
I had that to.
Sometimes it doesn't load well. Doesn't mount the drive or something.
It worked later so maybe a full page reset solves that.
Edison once said,
"I have not failed 10,000 times,
I've successfully found 10,000 ways that will not work."
---------
Currently running over 20 separate instances of Stunts
---------
Check out the STUNTS resources on my Mega (globe icon)

HunterBoy344

Development update again!

I've managed to get the game to run at the correct speed on all hardware. As I suspected, the fixed 20000 cycles was too much for most users, so I changed the cycles=20000 to cycles=max to get the best possible cycles depending on hardware.

Hope this helps! I've already started working on some multiplayer functions, so expect another progress report soon!

Daniel3D

Well. I have a busy race schedule this weekend, and apparently no time to fulfill it. But I'll try to squeeze a test in for you.
Edison once said,
"I have not failed 10,000 times,
I've successfully found 10,000 ways that will not work."
---------
Currently running over 20 separate instances of Stunts
---------
Check out the STUNTS resources on my Mega (globe icon)

alanrotoi


Daniel3D

CAS, can this be combined with easy tour?
So one can race the current track in the browser (save replay in game) or download the track and upload the replay.
Edison once said,
"I have not failed 10,000 times,
I've successfully found 10,000 ways that will not work."
---------
Currently running over 20 separate instances of Stunts
---------
Check out the STUNTS resources on my Mega (globe icon)

Cas

Uhm... I really wouldn't know how to interact with that software. I suppose one website should send a file to the other via POST and the other one should place it where it's supposed to be. If the tournament is the receiving website, the DOSBox host should have the ability to recognise when a RPL file has been created and immediately try to send it to the tournament website, which should react and receive it and place it where it's needed. In the other direction, it's even more complicated, because DOSBox normally does not see files until you do a Ctrl+Shift+F4, if I remember correctly.
Earth is my country. Science is my religion.

HunterBoy344

New development update!!!

If you check the website, you'll probably notice a few new things that weren't there before: a small frame above the main em-dosbox window, and a connection input form below it! The small frame is going to be used for a indicator of how much time is left in the match, and the connection input form is used to connect to a WebSocket server. All of this is visible on the webpage right now, though it is incomplete.

Behind all of that new stuff in the UI lies a lot of new JavaScript code! I've added some code for WebSockets and I now have a system in place for interpreting different responses from a server. It's pretty efficient and organized, so I think it'll work well once I've written code for the server.

That's all for now! Just wanted to fill you all in on what I've been working on. I might add a chat as my next feature, just to get some aspect of multiplayer working.

HunterBoy344

Quote from: Cas on June 30, 2022, 03:57:03 AM
Uhm... I really wouldn't know how to interact with that software. I suppose one website should send a file to the other via POST and the other one should place it where it's supposed to be. If the tournament is the receiving website, the DOSBox host should have the ability to recognise when a RPL file has been created and immediately try to send it to the tournament website, which should react and receive it and place it where it's needed. In the other direction, it's even more complicated, because DOSBox normally does not see files until you do a Ctrl+Shift+F4, if I remember correctly.

This issue with DOSBox actually applies to my project even without Easy Tour stuff, so thank you for bringing it up! I did a little research, and as it turns out, DOSBox (and em-dosbox by extension) caches files for all drives EXCEPT drives mounted as floppy drives. To solve this, I changed my em-dosbox export to load a custom batch file I made instead of just STUNTS_K.EXE. The batch file simply mounts the folder containing Stunts a second time as floppy drive A using mount A / -t floppy, then changes to that drive and runs Stunts. While the newly mounted floppy drive A and the previously mounted hard drive C both reference the same folder in the Emscripten file system, drive A will update its files whenever the Emscripten file system changes and drive C will not.

Now that I've made these changes, I can freely load new tracks and other files into em-dosbox live without having to worry about caching! I've already given it a test by using Emscripten's FS.mkdir command in the JS console, and sure enough, the folder I created in the Emscripten file system was instantly visible in drive A!