Stunts Forum

Stunts - the Game => Stunts Related Programs => Topic started by: HunterBoy344 on June 24, 2022, 01:16:59 AM

Title: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: HunterBoy344 on June 24, 2022, 01:16:59 AM
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 (https://stuntsonline.hunterboy344.repl.co)
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: HunterBoy344 on June 24, 2022, 02:34:17 AM
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.
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: 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.
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: Daniel3D on June 24, 2022, 07:54:55 AM
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.
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: Daniel3D on June 24, 2022, 09:53:30 AM
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.
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: HunterBoy344 on June 24, 2022, 04:17:17 PM
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.
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: 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.
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: Daniel3D on June 24, 2022, 10:33:19 PM
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.
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: HunterBoy344 on June 25, 2022, 07:09:45 PM
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!
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: Daniel3D on June 25, 2022, 08:22:22 PM
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.
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: alanrotoi on June 28, 2022, 02:54:58 AM
Also it would be cool a "spectator mode" :)
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: Daniel3D on June 28, 2022, 12:38:01 PM
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.
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: 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.
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: HunterBoy344 on July 02, 2022, 08:34:07 PM
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.
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: HunterBoy344 on July 04, 2022, 03:42:49 PM
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!
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: alanrotoi on July 04, 2022, 07:05:10 PM
I follow your work with great expectation. Unfortunately I can only contribute with ideas.  :)
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: Daniel3D on July 08, 2022, 12:03:41 PM
It is working a lot better now. I can even drive it on my chromebook (not the strongest pseudo-computer)
But i have no sound.
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: Daniel3D on July 10, 2022, 08:25:44 AM
an idea to get scores out of the game. (don't know if that can work)
If you save the replay in the game, does that get uploaded to the server?
and is that file identifiable per user (by source ip or something)?
then you could have a scoreboard on the site..
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: alanrotoi on July 10, 2022, 02:11:23 PM
Would that need multiple stunts sessions? Can it run seversl stunts at the same time? What if two pipsqueaks saves a replay with the same name? We would need to register a user.
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: Daniel3D on July 10, 2022, 02:21:54 PM
Quote from: alanrotoi on July 10, 2022, 02:11:23 PM
Would that need multiple stunts sessions? Can it run seversl stunts at the same time? What if two pipsqueaks saves a replay with the same name? We would need to register a user.
The game runs local. O yes multiple simultaneous sessions are possible. But registration and filetracking would be needed. I don't know if that is possible.
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: HunterBoy344 on July 17, 2022, 04:13:28 AM
Quote from: Daniel3D on July 10, 2022, 08:25:44 AM
an idea to get scores out of the game. (don't know if that can work)
If you save the replay in the game, does that get uploaded to the server?
and is that file identifiable per user (by source ip or something)?
then you could have a scoreboard on the site..

It actually can work, and I just finished making it work!

Yep, time for another dev update: I've (mostly) finished the entire client! I have yet to add a chat, but other than that, all of the functions and page elements are there. I do not yet have a server, but I've organized my client fairly well and know what data the server has to send and receive to make the game work.

Alright, time to talk about the new features. You'll notice when opening the webpage that there are now two new iframes below the game. The first iframe is a leaderboard, and HTML data sent by the server will be inserted there to display scores. The second is a chat, though there is no code for it yet. I intend to get the core multiplayer itself working first. Behind the scenes, I've added automatic replay checking (so that the client instantly sends a replay to the server once it is created), a warning indicator to return to the main menu 10 seconds before the track changes, and some various other improvements. All in all, the client should have everything needed to interact with the server.

I'm on vacation right now, so I might not be able to provide updates as frequently, but I'll get working on the server as soon as I can.
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: HunterBoy344 on July 17, 2022, 04:15:36 AM
Quote from: alanrotoi on July 10, 2022, 02:11:23 PM
Would that need multiple stunts sessions? Can it run seversl stunts at the same time? What if two pipsqueaks saves a replay with the same name? We would need to register a user.

You raise a fair point about replay submissions. I'll set up the server such that it closes the connection if the username provided on connection matches another user already connected. I may also associate usernames with IPs later to completely remove this problem.
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: alanrotoi on July 17, 2022, 06:15:36 AM
You are doing an excellent job! Thank you! I feel we can do great events with this project.
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: HunterBoy344 on July 17, 2022, 04:42:00 PM
Quote from: alanrotoi on July 17, 2022, 06:15:36 AM
You are doing an excellent job! Thank you! I feel we can do great events with this project.

Thanks so much for your support! I really hope my project can open up new possibilities for the Stunts community.
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: Daniel3D on July 17, 2022, 09:37:59 PM
Quote from: HunterBoy344 on July 17, 2022, 04:15:36 AM
I'll set up the server such that it closes the connection if the username provided on connection matches another user already connected. .
To force popularity I can login as duplode or ctg and set a rubbish time. Honour would force them to login and rectify this monstrosity. But if they participate others will have to follow or they loose face..

It's flawless. Can't fail.  ;D ;D
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: dreadnaut on July 18, 2022, 08:47:22 PM
Somewhere I should still have that "Login with ZakStunts" experiment meant for R4K. Further down we could see if we can make it work here ::)
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: Daniel3D on July 18, 2022, 09:53:23 PM
Quote from: dreadnaut on July 18, 2022, 08:47:22 PM
Somewhere I should still have that "Login with ZakStunts" experiment meant for R4K. Further down we could see if we can make it work here ::)
i think that it would benefit CAS his easytour as well. (totally not a selfish remark at all... ::) )
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: Cas on July 20, 2022, 02:41:15 AM
Login unification?  That sounds interesting. I had been thinking of something related. I have a little project I'm working on and it currently uses R4K login system and I had thought of whether it could be separated, but still use it as a form of validation. Now You make me think we could somehow unify the whole login system. Shouldn't the forum also have login integration with ZakStunts?

In Race For Kicks, users have some local characteristics such as an avatar and some flags that might stay internal even with a unified login system, but I could also potentially share that as well. Count on me for any of this. Also, I have left pending that idea about displaying the current race in the hub so all that might be done as one thing. Maybe we should create a topic for this. Alright... let's go one with pseudo-multiplayer here.... I'l make another topic :P
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: HunterBoy344 on July 28, 2022, 05:07:02 PM
(https://media.discordapp.net/attachments/1001987443219779746/1002010796907302943/unknown.png)

Screenshot of a test I did yesterday!

I added the race timer and working track distribution for the server. I have a few more things to add, but I plan on hosting a public online play test soon!
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: Daniel3D on July 28, 2022, 09:44:06 PM
Hey. It looks good.
A few practical ideas. We can make a game executable that has a different car as default.
If you also use default as track you only have to select drive to race.
On the evaluation screen we can place save replay instructions by editing the background.
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: HunterBoy344 on July 29, 2022, 07:22:14 PM
Quote from: Daniel3D on July 28, 2022, 09:44:06 PM
Hey. It looks good.
A few practical ideas. We can make a game executable that has a different car as default.
If you also use default as track you only have to select drive to race.
On the evaluation screen we can place save replay instructions by editing the background.

Very interesting ideas! I don't know how to change the background or modify the executable, but something like that would definitely make sense. If you're able to make that, I'll gladly add it in to the site.

As for the default track part, I already thought of that, and it unfortunately won't work. As I discovered, Stunts caches whatever track is currently loaded, meaning that even if DEFAULT.TRK changes, the new track won't actually load unless the user manually reloads the track file from the main menu.

However, I have found a way to make the track selection a little more convenient! I have changed the name of the server track to 01SERVER.TRK. By adding the 01 to the beginning, the track is by default placed at the top of the tracks list. In other words, one only has to press enter twice to load the current track in the tracks menu. It isn't perfect, but it's better than before!

Before I post this, I'd also like to mention something. Replay files are great and all, but... what if I used high score files instead? I don't know all of the details, but I do know that more accurate times are stored in high score files (even including penalties!) and that they are ONLY updated when a user actually crosses the finish line, meaning that they can automatically be sent whenever a user finishes AND that it is impossible to submit a crash or early end as a valid time. While it would be possible for a cheater to add in their own custom high score file, it's also possible for a cheater to add their own custom replay, so there aren't really any new risks.

Let me know what you think!
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: Daniel3D on July 30, 2022, 12:50:10 AM
well, it is not a problem to make, just tell me if you want a different car as default (the indy for instance)

I tested the site, and the game runs really smooth, but i still dont have sound.
it is possible, https://www.myabandonware.com/game/stunts-10y/play-10y (https://www.myabandonware.com/game/stunts-10y/play-10y)
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: HunterBoy344 on July 30, 2022, 12:59:12 AM
Very important dev update!

I tried using highscore files instead of replays, and it worked really well! Times are now submitted automatically only when the race is completed, meaning cheating is harder, and users no longer need to manually save replays to submit their times. Additionally, tracks now go by their original names, and all other default Stunts tracks and highscore files are removed upon connection to a server to keep things organized. The warning displayed when a round ends now is more verbose, so users know how to load the new track when it updates, and a basic explanation of the gameplay loop for new users is now below the login form.

Here are some screenshots of a private test I did today! The server was able to handle all 6 players, though it did notably crash when someone tried to paste the entire Bee Movie script as their username.

(https://media.discordapp.net/attachments/713351978729865238/1002707328031793162/playtestscreenshot1.png?width=982&height=451)

(https://media.discordapp.net/attachments/713351978729865238/1002708423323947140/playtestscreenshot2.png?width=982&height=453)

Everyone was able to figure out how to play quickly despite having never seen Stunts before, so I think most new players will be able to get the hang of it without a detailed explanation! I can't wait to host a public play test!
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: HunterBoy344 on July 30, 2022, 01:04:09 AM
Quote from: Daniel3D on July 30, 2022, 12:50:10 AM
well, it is not a problem to make, just tell me if you want a different car as default (the indy for instance)

I tested the site, and the game runs really smooth, but i still dont have sound.
it is possible, https://www.myabandonware.com/game/stunts-10y/play-10y (https://www.myabandonware.com/game/stunts-10y/play-10y)

The Indy would be good! Definitely the ideal car for new players. It might actually take a bit for me to add the updated executable though, since I'd have to remake the emscripten .html and .data files and add all of the page elements from the previous version to the new one.

As for sound... I know it's possible and I've seen it working, it's just that the version of em-dosbox I've been using doesn't support it for some reason. I was able to find a version that does, but it didn't compile. If I can get it to work, then sound might be possible, but it definitely won't be in the first play test.
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: HunterBoy344 on July 31, 2022, 03:37:57 AM
Short dev update!

I figured I'd actually make the website look nice, since most of the logic is done. Here are the results!

Before:
(https://media.discordapp.net/attachments/713351978729865238/1002707328031793162/playtestscreenshot1.png?width=982&height=451)

After:
(https://media.discordapp.net/attachments/906624838230224926/1003108351179243590/unknown.png?width=966&height=482)

Still need to finish styling the timer, but it'll all be ready soon! I'm thinking of doing the first public test on Wednesday, but I'm going to make sure my new visual changes haven't broken anything before I decide on an official date and time.
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: HunterBoy344 on August 22, 2022, 02:23:25 AM
Hey, haven't posted on this thread for a while, but here's some stuff that's changed!

As of version 2.1...

- Added sound
- Added mouse support
- Switched entirely from em-dosbox to js-dos
- New wallpaper
- Added support for uploading and downloading files while not connected to a server
- Updated localization fi-- wait, wrong game

Thanks for sticking with the project! My next priority is definitely live chat, which will come with version 3.0. 3.0 will also require an update to the server. Right now, StuntsServer version 1.0 is still completely compatible with Stunts Online 2.1!
Title: Re: Working on a pseudo-multiplayer system for Stunts using em-dosbox and WebSockets
Post by: Cas on August 25, 2022, 07:30:35 PM
Great work, mate!  When I manage to get some time, I'll make some test to see how I can make it run normally on my computer