To develop a SmartGlass experience, you create multiple pieces of code that run in different places. Some of the code runs on the Xbox One console, and some of the code runs on the SmartGlass-enabled devices that one or more players are using to interact with the Xbox One console.
One way to understand how to create and integrate these different pieces of code is to examine some of the existing samples that are available for SmartGlass. The Snake Battle Arena sample is a particularly useful sample to use for this purpose.
To get the Snake Battle Arena sample, install the SmartGlass Hosted Companion SDK. The sample is in the Samples\SBA folder in the folder to which you extract the .zip file for the SDK. To view a video that features the Snake Battle Arena sample, see Snake Battle Arena for SmartGlass.
In the Snake Battle Arena game, each player guides the movement of a snake across a playing area in pursuit of food, so that their snake can grow longer. If a snake collides with the walls at the edge of the playing area or with another snake, the snake dies and the player has to start over.
With Snake Battle Arena sample for SmartGlass, the players can use their SmartGlass-enabled devices to control the movement of their snakes. If a player has a SmartGlass-enabled device that has acclerometer support, the player can tilt their device towards the top, bottom, left, or right to instruct the snake to make the corresponding turn in the game. The sample uses a device-side SmartGlass API to take the accelerometer readings on the SmartGlass-enabled device and send those readings to the Xbox One console, where the sample uses a console-side SmartGlass API to receive those readings and then processes them as appropriate for the game.
Before you can deploy and run the Snake Battle Arena sample, you need to perform the following prerequisite tasks:
If you performed the prerequisite tasks, you can build and deploy the Snake Battle Arena game to your dev kit from Visual Studio, and open the Snake Battle Arena companion in SmartGlass Studio on your SmartGlass-enabled device to start playing the game.
As an example of a SmartGlass experience, the Snake Battle Arena sample includes both code that runs on the Xbox One console and code that runs on a SmartGlass-enabled device. The code in these locations communicate with each other using messages, and that communication provides the means for the Xbox One console and SmartGlass-enabled device to interact.
The Snake Battle Arena sample is a Visual Studio solution that contains the following projects: