melonJS multiplayer with Node.js/socket.io

787 views
Skip to first unread message

Justin

unread,
May 22, 2013, 12:28:09 PM5/22/13
to mel...@googlegroups.com
I know there's always a lot of chatter about this, but I haven't seen any open source implementations yet.

It's a very simple implementation of node, socket, and melonJS (i.e. no goals, levels, etc; only movement and networking). Also note there is no interpolation built in yet, so the movement is definitely a little jaggy (that's next on the todo list). But it works, and anyone is free to fork / use whatever if it helps.

Jay Oster

unread,
May 22, 2013, 3:07:12 PM5/22/13
to mel...@googlegroups.com
I was going to create a gh_pages branch so I could run the game directly on github, but there's still the issue of running the nodejs server. Also, this: https://github.com/parasyte/spidersoliders/blob/master/js/game.js#L8 makes it impractical to use as a demonstration of multiplayer gaming over the internet. ;(

Next, I tried running the server locally, and discovered the following missing dependencies:
  • mime
  • crc
You already have a node_modules directory, it's just missing some stuff.

Then I finally got it running! Yay! The jumping/gravity is really wonky, though. It feels stiff and unnatural. I made some changes to fix that: https://github.com/parasyte/spidersoliders/commit/d3aedb9daac4df486d9c1b8af7fb2d139eb11496

The last thing I'm looking into is why it runs slow on Chrome but fast on Safari. Not sure about this one, yet.

Justin

unread,
May 22, 2013, 3:20:28 PM5/22/13
to mel...@googlegroups.com
Oops! I probably accidently installed some node dependencies globally. And, yeah, it's really a pain to get node.js with WebSockets running anywhere. I got a (free-ish) host, but I'm waiting to see if the open source license clears. 

Good call on the jumping changes.I knew it felt off, but my brain isn't working.

This version on GitHub has a step limiter to slow down the number of updates going back and forth, if you take that out, things smooth a little. It runs well locally in Firefox and Safari. Haven't tested much on Chrome yet. I would have just used PubStub, but I'm mostly trying to use this as a learning experience. Trying to figure out interpolation will be fun!

Aaron McLeod

unread,
May 22, 2013, 3:21:25 PM5/22/13
to mel...@googlegroups.com
If you really want something cheap to test with, just get a vps from http://digitalocean.com. $5/mo and you get a pretty decent box, just 1 cpu core though.


--
You received this message because you are subscribed to the Google Groups "melonJS - A lightweight HTML5 game engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to melonjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Aaron McLeod
http://agmprojects.com

Jay Oster

unread,
May 22, 2013, 3:53:41 PM5/22/13
to mel...@googlegroups.com
Yes, it's a good start. One of the interesting challenges you'll face is message distribution speed when your server is hosted. (When running locally, there's literally no latency.) Actual latency will depend entirely on your host's interface with the internet. Most datacenters will have a solid backbone, but I would be careful about any of the lesser known VPS hosts; Especially if they oversell capacity. The reason I bring it up is because latency is a showstopper for any multiplayer game. And multiple factors affect latency, including CPU and bandwidth headroom, but even more importantly is geographic distance.

Justin

unread,
May 22, 2013, 5:08:37 PM5/22/13
to mel...@googlegroups.com
I still have some AWS free time left, so I set up a quick and dirty EC2 node server, and threw up the current version of my game here for testing purposes for anyone who's curious:

http://justinoblak.com/portfolio/games/spidersoldiers

The Chrome slowness vs. Firefox and Safari is very strange. Especially since it doesn't seem latency-related, and the entire engine slows down..

Jason Oster

unread,
May 22, 2013, 7:24:57 PM5/22/13
to mel...@googlegroups.com, mel...@googlegroups.com
Surprisingly, when I kill the node server and let chrome continue running the game, the performance improves instantaneously. That seems to indicate an issue related to socket.io, but I can only speculate, as I haven't looked into it.
--
You received this message because you are subscribed to a topic in the Google Groups "melonJS - A lightweight HTML5 game engine" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/melonjs/X6kpO2EdDf8/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to melonjs+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages