WebPong – instant WebSockets-based multiplayer mode

WebPong was supposed to be a multiplayer clone of Pong running on WebSockets and WebGL/BabylonJS library for 3D graphics. As it turned out that pong in real 3D (6 degrees of freedom) isn’t really that much fun, I decided to convert it into a simple ball shooting game with a couple of rules: at most 5 balls can be launched by each player at a time, ball lifetime is 5 seconds, ball becomes “activated” when it collides with something, a player gets killed after being hit by any active ball 5 times. Players are represented as pyramids flying around completely freely within a box scaffolding. Now, to the cool feature of this software. In order to play the game with your pal, all you have to do is open either http://algoholic.eu/webpong/ or https://algoholic.eu/webpong/ (if WebSockets on port 80 do not work for you; check http://www.websocketstest.com when in doubt), then pass her the address you’re redirected to and voila! The second she opens the page you’re both playing your very own private match. It’s my courtesy to donate some bandwidth to this game at least for the time being. If it gets too popular I reserve the right to take the server down πŸ˜‰ The purpose was just to demonstrate what I consider friendly two-people multiplayer, without registering, “creating” games or figuring out how to join the same existing table/lobby/match. I could probably patent it in the crazy world of patent trolls but who really cares, I just want to have fun πŸ˜‰ Plus by publishing this right now I’m closing the door for anyone to patent it in the future. Surprise “geniuses” lol, it’s elementary. No easy patents for ya. It’s also the only multiplayer example of using BabylonJS that I’m aware of. The controls are A/W/S/D for movement, click and drag the mouse to look around, SPACE to shoot.

There’s one more juicy bit left to the story, the one for more tech-savvy readers. It’s about how I set up the WebSockets server. So, I decided to give NodeJS a go. It was a breeze to get WS running using the WebSockets-Node module, however then I had an issue with Apache which was handling all of my HTTP(S) traffic. As WS proxying support has been added to Apache only very recently and I didn’t want to go through any incompatibility problems with the new version and my legacy config files, I decided to switch the roles and put another NodeJS application on the forefront to distribute the requests properly. Using http-proxy I wrote it in such a way that all HTTP(S) requests are forwarded to Apache, while all WS(S) requests get proxied to the WebPong WS server. Neat, huh? Like this, we’re all happy. To give all the due credit, NodeJS apps are sustained using forever.

Alright, people. So that’s it for the first post of year 2014. Sorry for the long break but I had to put myself back together after Xmas laziness and also needed to get the hang of my new job position (which is Software Engineer in the Blue Brain Project team). So now, invite your friends and enjoy the game, please πŸ™‚ Cheers!

Leave a Reply

Your email address will not be published. Required fields are marked *