There are some solutions out there that turn your smartphone into a Wii-style controller, but many of them require a dedicated app on your phone and even a browser plugin on your desktop. With HTML5 and WebSockets you can achieve this very quickly and easily without the need of pre-installing anything on your machine or your phone.
All you need is:
- A desktop browser: The game is “hosted” by the desktop browser. It renders the UI of the game using HTML5 canvas and WebGL.
Note: You can check here if your desktop browser supports WebGL.
- A WebSocket server: The desktop and the smartphone(s) have to communicate through a fast, low latency channel – exactly what WebSocket was designed to do. The WebSocket standard doesn’t provide peer-to-peer connectivity, so you’ll need a server that routes the messages between the smartphone(s) and the desktop.
The flow for the player is very simple:
- Bring up the game in your desktop browser: http://demo.kaazing.com/racer
- Enter the URL in your smartphone browser, as shown in the bottom of the desktop browser: http://demo.kaazing.com/racer/ws
- Enter the unique ID when prompted by your smartphone. This unique ID connects the game instance running in your desktop browser to the smartphone you use as your remote controller.
After watching the video how it works, take it for a test drive.