Free up to 1MM monthly messages. No credit card required.
I recently stumbled across the awesome Voxeljs library which allows anybody to create Minecraft style games (Voxel) that run in the browser with NodeJS. In this tutorial, we’ll walk you through how to develop multiplayer Voxeljs to build a DIY Minecraft!
I decided I was going to take an afternoon to add the power of PubNub to Voxeljs, creating the basis for an MMO version of Minecraft. Want to see it in action and go for a stroll around? Here’s the multiplayer Voxeljs demo.
I modified the “hello world” example to include our standard PubNub initialization.
First I added the script into index.html.
And then I initialize PubNub. In this special case the
PUBNUB object needs to be referenced by
Then I created a
User object and list of
Users so I could keep track of who was online and what their position in game was.
pubnub.subscribe, and add a player when I get a join event. I subscribe to notifications on our channel, and update the player position when I receive a message.
All that’s left is to send out player positions! I use
setInterval() to publish the player position every second.
That’s it! It’s very crude but was easy enough to set up in an afternoon. We can open two windows and see the player position update in real time. It wouldn’t take much to add smoother animations and the ability to place and delete blocks.
Want to see it in action? Check out the live multiplayer Voxeljs demo here, or watch the quick overview video below:
A roundtable discussion led by PubNub’s COO, Casey Clegg, exploring the topics of what it means to be human in a virtual world.
Dr. Joe Kvedar, Chair of the Board for the American Telemedicine Association, joins our COO, Casey Clegg, to discuss why...
Today, we are glad to announce that we are currently in the process of implementing ISO-27001 security standards.