1 (edited by eeeee 2015-04-20 08:19:06)

Topic: [CLIENT] teewebs.net - JavaScript Port

tl;dr: You can play Teeworlds in your web browser now: http://teewebs.net

After more than half a year of work I'm ready to present the JavaScript Port of Teeworlds-based client.
I've used the Emscripten transcompiler on the DDNet client C++ source to generate the JavaScript code, runnable in browser.
DDNet client was chosen as a base for its good support of DDRace and other modifications, and already existing support for Android platform which has restrictions that are somewhat similar to JavaScript (such as no relative mouse input).

Supported browsers: Mozilla Firefox, Google Chrome.

Source code: https://github.com/eeeee/ddnet/tree/js. I tried to keep the patch as small as possible to make it easier to update, and will merge it into the DDNet repository soon.

Notable differences with the C++ version:

  • Graphics is rendered using WebGL.

  • Communication with the game server is carried over the WebSockets protocol as it's not currently possible to use UDP from a web browser directly.

  • Most textures are loaded asynchronously from HTTP, to reduce the loading time. Maps are downloaded from HTTP as well (DDNet client feature).

  • Supports dynamic window resizing.

  • All of the server browser information is pre-populated on our servers, and then fed to the client in one JSON blob. This was necessary because it's not possible to establish WebSockets sessions with each server fast enough to fetch the server infos and populate the server list at a reasonable rate. We use geolocation to estimate the server latencies.

  • Map layers are stored in memory RLE-encoded (except for the game layer, used for collision). Substantially reduces the memory usage on maps with many layers (e.g. from 59MB down to just 10MB on Kobra map).

Known issues and future improvement:

  • No sounds. Should be easy to fix but not the top priority right now.

  • Mouse input feels weird at times (e.g. spectator free mode). This is because the interaction of game code with the browser's mouse pointer lock feature is very hard to implement correctly without massive modifications to the game code.

  • WebSockets is TCP based, so while it has acceptable performance on good connections, it works extremely poorly on connections which have even minimal amount of dropped packets. It might be possible to workaround this situation by creating and multiplexing multiple WebSockets connections to reduce the stall time after a dropped packet.

  • Teeworlds uses an old version of OpenGL APIs, which is not directly supported by WebGL, so it has to be emulated with a certain performance hit.

  • Everything is synchronous, which increases ping and causes a bit more lags. It might be possible to offload the network handling and ticking to a WebWorker, keeping only the WebGL rendering on the browser's main thread.

  • Nothing is stored locally, so there is no way to persist changes to configuration variables (such as player name). Using the Emscripten's IDBFS for adding local storage capability looks easy.

  • Because JavaScript client cannot connect to an arbitrary Teeworlds server and special serverside support is required, only WebSockets-enabled whitelisted DDRaceNetwork servers are visible in the server browser at the moment. If there is enough interest, we will develop a process for making your own server compatible with JavaScript client.

Questions? Meet us on IRC, we're hanging out in #ddnet on Quakenet.

This was a huge effort, and it would not have been possible without deen, fstd, Learath2, all other fellow tees who helped with testing and pr0tips, and the original Teeworlds, DDRace, DDNet developers. Thanks everyone!

http://teewebs.net

2

Re: [CLIENT] teewebs.net - JavaScript Port

Awesome yikes !!!!!

3

Re: [CLIENT] teewebs.net - JavaScript Port

great job.

How i can?
I don't know!
Persian Client [https://www.teeworlds.com/forum/viewtopic.php?id=10991]

4

Re: [CLIENT] teewebs.net - JavaScript Port

This looks like an awesome project and it seems to work perfectly so far.
Although... I only see DDRace mods in the server list? Why can't I access most servers?

Not Luck, Just Magic.

5

Re: [CLIENT] teewebs.net - JavaScript Port

eeeee wrote:

[...]
Known issues and future improvement:

  • [...]

  • Because JavaScript client cannot connect to an arbitrary Teeworlds server and special serverside support is required, only WebSockets-enabled whitelisted DDRaceNetwork servers are visible in the server browser at the moment. If there is enough interest, we will develop a process for making your own server compatible with JavaScript client.

6

Re: [CLIENT] teewebs.net - JavaScript Port

This is impressive, eeeee smile

I've got to say the ddnet team has been doing quite a good job lately. I don't even play ddrace, but I downloaded your client a couple weeks ago and what I saw made me really happy for that part of the teeworlds community. Keep up the great work!

btw, where is that lamefun guy now, who kept asking for this ahahah

check out these maps: infiltrate - choco - dustycloud

7

Re: [CLIENT] teewebs.net - JavaScript Port

east wrote:
eeeee wrote:

[...]
Known issues and future improvement:

  • [...]

  • Because JavaScript client cannot connect to an arbitrary Teeworlds server and special serverside support is required, only WebSockets-enabled whitelisted DDRaceNetwork servers are visible in the server browser at the moment. If there is enough interest, we will develop a process for making your own server compatible with JavaScript client.

Does this mean that I cannot connect to a normal Teeworlds server, even if I enter its IP? Or is it just a masterservers thing?

Not Luck, Just Magic.

8 (edited by east 2015-04-20 15:55:56)

Re: [CLIENT] teewebs.net - JavaScript Port

Dune wrote:

[...]
Does this mean that I cannot connect to a normal Teeworlds server, even if I enter its IP? Or is it just a masterservers thing?

You cannot use native UDP sockets in Javascript, eeeee's client uses WebSockets which require an implementation of a WebSocket Server on the other side.
So you cannot connect to any normal Teeworlds Server.

9

Re: [CLIENT] teewebs.net - JavaScript Port

east wrote:
Dune wrote:

[...]
Does this mean that I cannot connect to a normal Teeworlds server, even if I enter its IP? Or is it just a masterservers thing?

You cannot use native UDP sockets in Javascript, eeeee's client uses WebSockets which require an implementation of a WebSocket Server on the other side.
So you cannot connect to any normal Teeworlds Server.

Alright got it!
It's still be a great way to introduce a potential new player to Teeworlds.

Not Luck, Just Magic.

10

Re: [CLIENT] teewebs.net - JavaScript Port

Dune: We do have a few Vanilla servers, they're just usually empty and the client filters out empty servers by default.

11

Re: [CLIENT] teewebs.net - JavaScript Port

Wow very nice! with something of work and time this can be awesome wink

P.S: Thx for discover me Emscripten :B

12

Re: [CLIENT] teewebs.net - JavaScript Port

deen wrote:

Dune: We do have a few Vanilla servers, they're just usually empty and the client filters out empty servers by default.

Great!

Not Luck, Just Magic.

13

Re: [CLIENT] teewebs.net - JavaScript Port

It's true that currently there are very few non-DDRace servers in the js client server list, however that's not because DDNet has a monopoly on js client access or anything. As I already mentioned we're open to helping anyone including the most popular vanilla servers to add the WebSockets protocol support (the patch is at https://github.com/eeeee/ddnet/tree/vanilla_ws ). The only problem is that we don't yet have a good way to easily check whether a certain server implements WebSockets or not, so the servers known to be compatible are just whitelisted at the moment.

14

Re: [CLIENT] teewebs.net - JavaScript Port

Wooh! Really cool, good job smile

Need a tool to manage your servers? teeman
<3

15

Re: [CLIENT] teewebs.net - JavaScript Port

eeeeeeeeeeeeeeeeeeeeeee you're such a try hard http://www.mpcforum.pl/uploads/images/1848114049394561122358.png
srsly tho well done cutiebuu~

Proud Instrument of [QQ]

16

Re: [CLIENT] teewebs.net - JavaScript Port

:thumbs up: smile
well done! this is rly cool.

Antoine de Saint Exupéry: It seems that perfection is reached not when there is nothing left to add, but when there is nothing left to take away.
Besides -  I am the gfx guy!

17

Re: [CLIENT] teewebs.net - JavaScript Port

They put it on the front page at http://ddnet.tw! congrats!..but it crashes my browser unless I close tabs to prepare for the embedded client xD
I get better fps on it than ddnet client, 1.33ghz quad core, 1gb ram winbook tablet. 400ms or higher ping on US server on stable network.
Doubletapping to fire also results in zooming o.O
Tested on IE11. Great fps, oddly derpy ping.. 70fps+ and very smooth.
AtheistCat, a friend of mine, had the idea of a server that the webclient could connect to which would essentially convert the packets to and from UDP and allow connecting to unmodified servers, at the cost of latency of course. Hopefully we'll live to see something similar implemented wink

Clan: Riot (I'm one of three leaders: Mile, Deku, pie)
Host teeworlds maps on a fng/ctf/dm/ddrace server for testing:http://riotproductions.tk/teewo/ broken-need reinstall nginx http://riotproductions.tk/bounce?whatEven, Teeworlds NA Discord chat

18

Re: [CLIENT] teewebs.net - JavaScript Port

Awesome work!

19

Re: [CLIENT] teewebs.net - JavaScript Port

I've tried the system on my low-end PC and 1.9GhZ Android Tablet but in bouth cases the mouse input seem kinda odd. Is that a client problem or a problem with my equipments?

Impressive work none the less.

Playing Teeworlds since 2011!
"I will always be topless for you"
                  - Günther Branlutte

20 (edited by Pathos 2015-05-15 04:20:02)

Re: [CLIENT] teewebs.net - JavaScript Port

This is very, very interesting. However, it's not working on IE. I do have certain settings on IE that might not let it work. It's javascript, so I thought I'd try on IE. What are some necessary settings on the IE? Also, what about Spartan?

21

Re: [CLIENT] teewebs.net - JavaScript Port

[Unfriendly post suggesting to use a different browser.] // heinrich5991

Having troubles finding servers in the serverlist? Go to Pastebin (its a referer cause there is daily a new pastebin) and add the lines to your settings.cfg (in %APPDATA%\teeworlds). Then open teeworlds and go to the favorites tab. (Note however, standard teeworlds client can only show 256 favorites, use ddnet instead)

22

Re: [CLIENT] teewebs.net - JavaScript Port

Schwertspize wrote:

[Unfriendly post suggesting to use a different browser.] // heinrich5991

You're encouraged to post helpful advice, but not in an unfriendly way.

23 (edited by [pieLover] 2015-05-16 00:27:56)

Re: [CLIENT] teewebs.net - JavaScript Port

Quite odd, I find it works better in IE11 than other browsers, particularly on low-end machines.

Clan: Riot (I'm one of three leaders: Mile, Deku, pie)
Host teeworlds maps on a fng/ctf/dm/ddrace server for testing:http://riotproductions.tk/teewo/ broken-need reinstall nginx http://riotproductions.tk/bounce?whatEven, Teeworlds NA Discord chat

24

Re: [CLIENT] teewebs.net - JavaScript Port

This is really impressive. Thanks for your effort.

Meuhmeuhmeuh xD

25 (edited by lamefun 2015-05-30 04:27:56)

Re: [CLIENT] teewebs.net - JavaScript Port

This is of course amazing, but IMO the lack of package management and client-side scripting (think Quake) is holding Teeworlds back a lot more than the lack of a Web client. I abandoned my Aviator mod because of it, and it also killed the Star Wars mod and the Nodes mod...