Hi.
My name is Daniel Rodriguez.
And today I will show you how to build
games and interactive applications
for the living room using Google Cast and the Game Manager APIs.
There are millions of Cast devices
ready for your amazing games.
The Cast model introduces a new exciting game experience.
Players can use their phones as dynamic game controllers
with the TV.
There's a lot of opportunity for innovation here.
Mobile devices have powerful sensors and touch screens
that we can use to our advantage.
Just imagine advancing through a dungeon with your friends,
using your phone screen to draw arcane symbols to cast spells
while your body physically runs around the living room
to cast a protective shield around you.
In order to build that kind of experience,
all the devices need to share information.
Thankfully, you won't have to spend your time
writing and testing code to synchronize them.
The Game Manager API helps you with this, particularly
in the case where the Cast device is
responsible for rendering on the TV
and hosting the majority of the game logic.
Getting your game ready for Google Cast
means understanding three parts of the Game Manager API.
First we have Senders.
These are the player's mobile phones, tablets, or laptops.
Android, iOS, and Chrome are all supported.
Next, we have the Cast Receiver.
That's the TV connected with a Cast device, like a Chromecast.
Finally, there is information exchange between the senders
and the receivers.
There are a bunch of different game types
that can take advantage of the Game Manager API,
from turn based to real time game play, which
is why we support the ability to have
multiple players on a single sender device.
And all of these APIs can be used
in combination with Google Play game services
to implement features like leaderboards and achievements.
So here's how it works.
All the synchronization between players
is handled through the Cast receiver.
You know, like a Chromecast connected to your TV.
This acts like a server for the match
and will store the game state, and will
take the role of pushing notifications
to devices once the information is available.
Players can make requests to change their state
and send game messages to the receiver.
Player's state can be used to implement features
like a lobby system.
It is also used to indicate that a player has been disconnected
and to reconnect that player.
Let's look at the APIs for sender devices.
The sender APIs are available on Android, iOS, and Chrome,
and work the same across platforms.
All request operations performed by the sender device
are asynchronous.
To connect the sender and register a player,
first, you must initialize the Cast SDK.
Check out our dev site to get more information.
Once this is done, you'll be ready to request a Game Manager
Client instance.
It contains a copy of the entire state on the receiver device
and will be updated automatically.
From this point on, you can read the current state,
send game messages, and make player requests.
A player request is a message used to register new players
and change their player state.
A game message represents player's actions.
Its contents are entirely up to your game.
The Game Manager Client always has
a snapshot of the receiver state,
and it's updated automatically.
This means you can query any value at any time,
like the number of players or the lobby state.
You can attach a listener to get notified when something changes
or when a game message is received.
Now let's look at the receiver APIs for the HTML5 game running
on the Google Cast device.
This is my favorite part, since this
is where the majority of the game code lives.
To get started, follow instructions on our dev site
about how to set up a receiver and then construct the Game
Manager object.
Unlike the sender APIs, all operations you perform
are synchronous since everything happens on the same device.
When you update any piece of Game Manager state,
a message will be sent automatically
to all connected senders letting them know of the change.
Much like on the sender APIs, you
can set up listeners to get notified of state changes
and game messages.
To send messages to players, you just
have to specify the player ID and the message.
We'll take care of the rest.
But we can't write perfect code every time, right?
To debug your game, you can connect the Chrome Remote
Debugger just like with any other Cast application.
You can enable a debug UI that is displayed on top
of your game on the TV screen.
We also provide you with a debugging app
for Android and iOS that allows you
to see the game state and messages being passed around,
as well as connect new players and update them.
To help you get started, we have open source game samples
that you can use for reference.
Make sure to check them out.
In summary, we provide you with the Receiver SDK, the Sender
SDKs for Android, iOS, and Chrome,
sample games that help you get started,
game debugger apps, and a debug UI for the receiver,
UX guidelines for Cast games, and all of the SDK
documentation and reference.
There are other ways you can use to create games
with the power of Google Cast.
If you want to have a phone or a tablet host the game logic
and push content to a TV, check out
the DevBytes video about Remote Display for Google Cast.
We're excited to see what kind of innovative games
you'll build using the Game Manager APIs for Google Cast.
Don't forget to check our dev site to get more information.
See you soon.
[MUSIC PLAYING]