Our next game will feature local multiplayer, and in this blog post series I will talk about the technologies that can be used to implement such feature, their platform support, and their implementation in Cordova.
Let's start by saying that by local multiplayer I don't mean two people playing on the same tablet, but I mean two people playing on the same room, each with his own phone/tablet.
There are a handful of technologies available to achieve that, each with its own advantages and disadvantages:
If you're a frequent reader of this blog, you already know that Bluetooth is a great option for local multiplayer games, at least on the Android platform.
It is very easy to set up and it also has Cordova bindings made by yours truly, but it also has its disadvantages:
- While it's possible to use it on Windows Phone, the MSDN documentation is rather confusing, and to this date there is no Cordova implementation for Bluetooth on that platform.
- You can't use Bluetooth RFCOMM directly on iOS (at least on a non jailbroken device).
This means that, for the moment, Bluetooth is great only for Android, and in the future maybe for Windows (Phone) too.
Wi-Fi might be a natural choice for implementing a local multiplayer game, its advantages are:
- It is based on open standards, which means the game can be played with one player using his iPhone, and the other player using his Android or Windows phone.
- It is faster and has a longer range than Bluetooth.
But, as no technology is perfect, it also has its own disadvantages:
- A Wi-Fi hotspot is needed in order to be able to use it, which may be a problem if you want to play while traveling
- It doesn't implement device discovery nativley, so methods like Bonjour or Zeroconf must be used, which complicates development.
What about Cordova bindings?
Well, you use standard TCP sockets, so cordova-plugin-chrome-apps-sockets-tcp and cordova-plugin-chrome-apps-sockets-tcpserver are available, while for Bonjour/Zeroconf there are a couple of implementations available, just search for them.
Bear in mind that none of the aforementioned plugins works on the Windows platform, so this is another (temporary?) disadvantage of this technology.
I haven't tried any of these Cordova plugins yet, so I don't know about their quality.
There are a couple more technologies available, and I will talk about them in the next blog posts, so stay tuned.