This past week I undertook a pretty cool project as the Intern here at Cykod. We were wondering how easily a smart phone –specifically using its gyroscopes and accelerometers– could be used as a controller for a multi-player game on a larger screen. With a bit of Node.js and HTML5 magic, it turned out to be pretty simple.
Concept :
We want to use a desktop (laptop, iPad, etc. something with a bigger screen that multiple players can easily look at) connection to act as the common game space. Once that screen is initialized, each player connects to a specific URL in their phone browser that links them to that game instance. We'll follow this basic outline:
- Register new connections to the server and decide if it is a room or mobile user:
- Create a new room,
- Or add the connection to an existing room
- Constantly poll the mobile device for orientation data
- Use said data to update the HTML5 Canvas game
- Handle dropped connections appropriately
Result :
The proof-of-concept full game is up at http://bit.ly/G4LSpaceWords