Issuu on Google+

Getting Started with OUYA

A practical guide to developing games for the revolutionary OUYA console

Ruben Hoyos Robinson Moncada


Getting Started with OUYA Copyright Š 2014 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: May 2014

Production Reference: 2290514

Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78355-145-3

Cover Image by Ruben Dario Hoyos Useche and Robinson Alexander Moncada Velasquez (,

Credits Authors Ruben Hoyos Robinson Moncada Reviewers Casey Leonard Matthew Traylor

Project Coordinators Sanket Deshmukh Sageer Parkar Proofreaders Simran Bhogal Ameesha Green

Preston Turner Commissioning Editors Martin Bell Erol Staveley Acquisition Editor Owen Roberts Content Development Editor Neil Alexander Technical Editors Krishnaveni Haridas Ankita Thakur Copy Editors Aditya Nair Kirti Pai Stuti Srivastava

Indexer Monica Ajmera Mehta Graphics Ronak Dhruv Production Coordinator Kyle Albuquerque Cover Work Kyle Albuquerque

About the Authors Ruben Hoyos is a systems engineer specializing in mobile development, with over

10 years of experience in IT projects, along with skills in project management and software development. He is also interested in video game development, augmented reality, and mobile technologies. He has experience in software development using technologies such as Microsoft .NET, Delphi, SQL Server, MySQL, and PHP. He is also interested in video game development using Unity3D and Vuforia. He is a certified Project Management Professional (PMP) from the PMI Institute. He is also certified in Microsoft Project. He has participated as a speaker in several events, such as Barcamp 2011, OUYA CREATE 2013, Barcamp 2013, Creative Transmedia 2013, and ViveLabs Ruta N (Medellin, CO). I would like to thank my wife Beatriz, my son John Paul, and all my family members for supporting me during this process. Also, I would like to thank the entire team at Packt Publishing; without them, this project would not be a reality.

Robinson Moncada is a multimedia development technologist with over five

years of experience in game development for PC and mobile. He has worked on a range of projects in modeling/3D animation, augmented reality, audio and video editing for video games and applications, and multimedia in biotechnology and military applications. He has experience in 3D modeling and animation programs, such as Maya, 3DMax, and Blender. He is also interested in video game development with Unity3D, Unreal UDK, and Vuforia (augmented reality). He has participated as a speaker in several events, such as Global Game JAM 2010, Expo Shangai 2010, Barcamp 2011, fLiSOL 2011, OUYA CREATE 2013, Barcamp 2013, Creative Transmedia 2013, and ViveLabs Ruta N (Medellin, CO). I'd like to thank my family for supporting me during this process.

About the Reviewers Matthew Traylor has been writing about software and games since the days of the TRS-80 and magazine program listings. He is a former technical writer for the first Linux certification program and a combat veteran. Recently, he founded the Sarissa Game Studio, a game development company that focuses on the implementation of conflict simulation and design using functional programming. Thanks to Steph, Dan, Hamburguesa, and all the fine folks at Packt Publishing.

Preston Turner is a computer programmer who began programming at the age

of 12. He has worked on projects involving general software development as well as game design across Mac, PC, and Android. He is self-employed and works with some of his friends on various projects. Support files, eBooks, discount offers and more

You might want to visit for support files and downloads related to your book. Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at for more details. At, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks. TM

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books.

Why Subscribe?

• Fully searchable across every book published by Packt • Copy and paste, print and bookmark content • On demand and accessible via web browser

Free Access for Packt account holders

If you have an account with Packt at, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.

Table of Contents Preface 1 Chapter 1: Why OUYA? 7 Technical specifications 8 Hardware 8 Controller 9 Software 10 OUYA is more than a console – it's a business model 10 OUYA – content restrictions 11 Marks or branding 12 Content scope, applications, and social networks 12 XBMC 12 TwitchTV 12 Onlive 13 VEVO 13 PLEX 13 Crunchyroll 13 Development tools to build video games for OUYA 13 Adobe Air 14 Android SDK/NDK (Java or C language) 14 Corona 14 GameMaker 15 MonoGame 15 Unity3D 16 Summary 16

Chapter 2: Setup Prerequisites Installing the Java Runtime Installing the Android SDK

17 18 18

Table of Contents

Installing the Android NDK 22 Installing and configuring Eclipse 23 Installing Unity3D 24 Configuring the Android SDK in Unity3D 26 Summary 26

Chapter 3: Setup Instructions for the OUYA ODK Creating an OUYA account Installing the console Downloading the ODK files Setting up the ODK in Windows and Mac OS For Mac OS For Windows Disabling Windows 8 driver signature verification

27 27 28 29 30 30 31


The OUYA emulator (Virtual Device) configuration 32 Executing the OUYA emulator 35 Summary 36

Chapter 4: Guidelines for Setting Up the OUYA ODK


Chapter 5: Configuring the Controllers


Starting with the OUYA Development Kit 37 The ODK plugin within Unity3D 38 Importing the ODK plugin within Unity3D 38 Installing and configuring the ODK plugin 39 Installing and configuring the Java class 42 Identifying the user 42 Starter kit – examples 44 Common errors while working with OUYA 45 Errors with the emulator 45 Errors with Eclipse 46 Errors with the ADB connection USB 47 Errors in the OUYA panel 47 Summary 47 Setting the controls 50 Creating the first scene of the game 51 Assigning the OUYA controls 54 The menu or system button 56 Differences between an analog joystick and a touchpad 57 Testing changes in the state of the button 58 Compiling and executing the game 60 Summary 62 [ ii ]

Table of Contents

Chapter 6: The OUYA Marketplace


Chapter 7: Advanced OUYA Functions – Graphics and Controls


Update your user profile 63 Configuring the items of purchase 65 Creating a game in the OUYA store 67 Creating the Key.der file 68 Programming access to the marketplace 69 A general guide to OUYA game content 70 Build settings 71 Testing the project with the emulator 72 Summary 73 Understanding shaders 76 Types of shader processors 78 The CG programming language for Nvidia Tegra 3 80 Characteristics of the Tegra 3 processor 81 Lighting 82 Multiple controls

Common problems Controller always pairing as the second controller The second OUYA controller paired as the third controller Summary


89 90 90 90

Chapter 8: The Future




Virtual reality – using Oculus Rift Arduino – the peripheral interface Leap Motion Nuidroid – 3D recognition for OUYA OUYA – the Free the Games Fund campaign Summary

[ iii ]

92 93 94 95 96 98

Preface OUYA is the new video game console, announced in July 2012, based on the Android operating system. Its main challenge is to be an alternative for independent developers and small businesses that do not have direct access to the major consoles in the market. Its economy model is based on the freemium scheme, where all the games and content published on the console should have one free component and another that you can monetize. Welcome to Getting Started with OUYA, a book that will guide you through the wonderful world of this console: its hardware, its configuration, how to build your first project for the console, and how to make money with it. In the first three chapters, you will learn the general features of the console: origins, business model, technical prerequisites, and preparation of the development environment. In the next four chapters, the book explains the code base used to build video games for OUYA using the Unity3D engine Version 4.x. The last chapter shows the technologies that are being developed for the near future and that directly or indirectly impact the development and advancement of the console: Leap Motion, VR Oculus Rifts, and Arduino, among others. The aim of this book is to let the reader know all the requirements and the basic tools to start your game development projects for the OUYA console. To facilitate learning and practice during the course of this book, we will use a Lite version of our (the authors') project, THE LAST MAYA, a video game based on the mythological Mayan culture and the end of the world.


What this book covers

Chapter 1, Why OUYA?, describes the origins of the project, the company, and its business model and gives an overview of the types of content that can be published in the console. Chapter 2, Setup Prerequisites, shows the readers all the technical prerequisites and basic configurations to prepare the development environment for Android. Chapter 3, Setup Instructions for the OUYA ODK, explains how to create a new developer account on OUYA's site, how to download and install the SDK development environment for OUYA (the ODK), and how to configure the emulator. Chapter 4, Guidelines for Setting Up the OUYA ODK, explains the contents of the ODK, installation and configuration of the ODK plugin to Unity3D, the starter kit, and common mistakes that can be made when starting a development project for the console. Chapter 5, Configuring the Controllers, explains how to start our first project for the OUYA console and goes over the basic configuration of the main scene and the main character, their animations, and how to associate them with controls. Chapter 6, The OUYA Marketplace, explains how to program the monetization of our video games using the integration features for OUYA's marketplace. Chapter 7, Advanced OUYA Functions – Graphics and Controls, explains all the basics that readers need to know to optimize the graphics of their games, leveraging the capabilities of the TEGRA 3 graphics processor by Nvidia. Chapter 8, The Future, describes all the emerging technologies that will impact the development and advancement of the console.

What you need for this book

Download the 4.x Version of the Unity3D game engine from https://www.unity3d. com. You should also download the SDK for OUYA (the ODK) from https://devs. Moreover, you should have all the prerequisites for Android development.



Who this book is for

This book is for beginners and advanced programmers who want to build video games for the OUYA console. From beginners to advanced users, this book allows anyone to address various issues related to development projects for the OUYA console.


In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning. Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Open the c:\progs\ adt-bundle-windows-x86\sdk\extras\google\usb_ driver\android_winusb.inf file with the Notepad editor or another text editor." A block of code is set as follows: ;OUYA Console %SingleAdbInterface% = USB_Install, USB\VID_2836&PID_0010 %CompositeAdbInterface% = USB_Install, USB\VID_2836&PID_0010&MI_01

Any command-line input or output is written as follows: adb kill-server adb devices

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Run the MANAGE | NETWORK option and configure your Internet connection." Warnings or important notes appear in a box like this.

Tips and tricks appear like this.



Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of. To send us general feedback, simply send an e-mail to, and mention the book title via the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.

Downloading the color images of this book

We also provide you a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from: default/files/downloads/1453OT_ColorImages.pdf.


Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub. com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from [4]



Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy. Please contact us at with a link to the suspected pirated material. We appreciate your help in protecting our authors, and our ability to bring you valuable content.


You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.


Why OUYA? OUYA was officially announced on July 10, 2012, on the Kickstarter web portal. The project began with a funding goal of 950,000 USD to develop the console prototype. The project was financed by Kickstarter backers (this is the term that Kickstarter uses to refer to users who sponsor a project). Within 24 hours, they had already raised more than 2 million USD. By the end, they had reached 8.5 million USD. This makes OUYA one of the most popular projects launched on Kickstarter. In December 2012, the creators began delivering developer versions of the console. The launch of OUYA through Kickstarter was an innovative way to raise funds for financing. The first units were sent out to backers on March 28, 2013. After some delays, the console was thrown open for purchase to the general public on June 25, 2013.

OUYA's Kickstarter crowdfunding campaign


The publishing system used by major video game companies was one of the motivations behind the OUYA project becoming a reality. The big companies monopolize the market for video games, and independent developers need to pay a lot of money to publish their creations. OUYA changed this situation, allowing small developers to publish their work directly to final buyers without having to pay large sums of money to the big video game publishing companies. The official website of the company is

Technical specifications

The OUYA system has the following technical specifications. The developer versions may vary slightly, but the retail OUYA console has the following standardized specifications.


The specifications of the OUYA console unit are as follows: • It has a NVIDIA Tegra 3 (T33) processor (four cores). The processor is optimized for graphics processing and web browsing. It has a CPU clock speed of 1.6 GHz and a GPU clock speed of 520 MHz. Because it doesn't have to worry about battery life, OUYA runs this processor at the full clock speed all the time. • Optimized for video games with high graphical quality, including the reproduction of video in 1080p HD. • 1 GB LPDDR2 RAM. • 8 GB internal storage (expandable by means of an external hard disk via USB). Only approximately 6 GB of memory will be used. The remaining memory will be used by the Android and the OUYA OS. A 16 GB version has also been launched recently. • HDMI connection to TV to 1080p HD (one connection). • LAN Ethernet connection via an RJ45 port. • Wi-Fi 802.11 bgn. • Bluetooth 4.0 LE. • USB 2.0 (one port). This is the port where components such as mice, keyboards, and storage can be hooked up to. It is sometimes called the inbound USB port.


Chapter 1

• Micro USB (one port). This is the port that you should use for hooking OUYA to your computer for development purposes. It is sometimes called the outbound USB port.

The OUYA pack


The specifications of the OUYA controller bundled with the console are as follows: • A wireless controller with a radio frequency of 2.4 GHz. This uses a standard Bluetooth connection. • A standard game controller layout (two analog joysticks, D-pad, eight action buttons, and one system button). • A touchpad, so that mobile games that are ported onto the system can be played more easily. • Battery operated; needs two AA batteries to power it.



• OUYA supports up to four controllers, as shown in the following diagram:

The control pad


The default software specifications of OUYA are as follows: • Android operating system 4.1 Jelly Bean • Custom TV UI • It has an integrated storage, which allows us to search and download games (and other applications) • Includes the SDK for development (OUYA ODK), which is available online for download

OUYA is more than a console – it's a business model

The console is the beginning of an ecosystem of businesses that want to leverage e-commerce systems with the aid of the "micro" transactions system. Video games are the category leader of the applications market, beating competition from categories such as entertainment, utilities, and productivity according to the trends of software consumption in the information era.

[ 10 ]

Chapter 1

The OUYA console is based on a system of monetization of games, referred to as the Freemium system, where the business model operates and consists of offering free basic services, combined with the option of purchasing additional items. The owner of a game published via the console has the opportunity to generate money in the following ways: • Selling the complete version of the video game (an unlocked version of the game or a version that has some restrictions removed) • Selling worlds or levels • Selling elements of the inventory, such as clothes, weapons, shields, and special powers The following variables are monitored in a Freemium business model: • Daily Active Users (DAU) • Monthly Active Users (MAU) • Index, which combines Daily Active Users versus Monthly Active Users The OUYA portal offers some basic level of analytics for developers, such as downloads and purchases.

OUYA – content restrictions

The company is very clear about the type of content that is permitted on the OUYA system. Explicit content is not permitted, including the following: • Any content promoting hatred toward a person or a group of people for their race, ethnicity, religion, disability, gender, age, sexual orientation, or gender identity • Any content that promotes violence in the real world, in any form • Sexually explicit material is forbidden in the contents of the console and their applications • Content that infringes on any copyright; the creators of the content must respect intellectual property and third-party copyright laws, including patents, marks, commercial secrets, and laws of authorship and others laws of property that are guarded • Viruses, worms, malware, or any other items that may harm the gamers or the OUYA platform

[ 11 ]


Marks or branding

You can utilize the OUYA name, logo, and commercial mark, but you must respect that they are the intellectual property of the company, for which they should receive credit. OUYA has an official manual of corporate identity that should be used. You can find it at

The corporate logo

Content scope, applications, and social networks

Besides the OUYA store, there are various media outlets, applications, and social networks that players and developers can use to reach out and make their games and content more popular. Some of these applications and networks include XBMC, TwitchTV, Onlive, VEVO, PLEX, and Crunchyroll, and we will learn about them in detail in the following sections.


The XBMC media center is an open source multimedia entertainment platform under the GNU GPL license. Its official website is


TwitchTV is an original service where players enjoy sharing their games with other users. It also offers its own chat tools and channels. This website has been functioning since 2011. In November 2012, Planet Side 2 was released, the first game that natively supports TwitchTV capabilities, but many others are coming. This can be a fun tool to show others your skills in various game types. Its official website is [ 12 ]

Chapter 1


Onlive is a video game distribution system that allows rental on demand (this means that you can rent the game for a few days or up to three years). This service is equivalent to cloud computing in the game industry, with the game being computed, rendered, and stored online. Onlive does not officially support OUYA, but you can get it to work by sideloading the APK on your system. Its official website is


VEVO is a music video site owned by Sony Music Entertainment, Universal Music Group, Abu Dhabi Media Company, and Arthur Music Company. EMI Music has given them the license to reproduce its content. Its official website is


PLEX is a media center that lets you organize the library of movies, series, and music. We can play it from the OUYA console and create a system of positive feedback for all the items related with high-level interactive content. Its official website is


Crunchyroll is an American website and international online community focused on streaming media such as anime, manga, music, video games, and racing from East Asia. Its official website is The important point is that you have software and services that attract users. The OUYA development company is in talks with Hulu, Netflix, Amazon, and Google for their services.

Development tools to build video games for OUYA

In this section, we'll take a look at some of the developer tools for the OUYA system.

[ 13 ]


Adobe Air

Adobe AIR is a free development framework and platform to create games and applications for mobile devices; it allows developers to create games for the OUYA console as it allows the creation of native applications for Android. Download the software from The official documentation for OUYA can be found at developers/docs/adobe-air. Download the examples for OUYA from

Android SDK/NDK (Java or C language)

The Android SDK is a free development framework based on Java that allows developers to make games using development IDEs such as Eclipse. The Android native development kit (NDK) is an alternative development framework that is free and allows you to develop native applications using the C or C++ programming languages. It is worth mentioning that in an application written with NDK, you may need to use the Java Native Interface (JNI) to make use of only the used functions from Java. Download the software (Android SDK / Android NDK) from http://developer. or ndk/index.html. The official documentation for OUYA can be found at developers/docs/android. Download the examples for OUYA from


The Corona SDK can be used for all types of mobile developers, from beginners to those with advanced knowledge of programming. It is a framework and SDK to develop games on the Android platform and OUYA. It also allows us to blend HTML5 with OpenGL or to use enterprise features such as access to a SQLite local database, JSON libraries, and asynchronous HTTP connection to store data in the cloud.

[ 14 ]

Chapter 1

The official documentation for OUYA can be found at developers/docs/corona. Download the examples for OUYA from


GameMaker is based on an interpreted programming language and software development kit (SDK) to develop video games. The program is designed to allow its users to easily develop games without having to learn a programming language such as C++ or Java. The program is free. However, there is an extended commercial version with additional features. Download the software from The official documentation for OUYA can be found at developers/docs/game-maker. Download the examples for OUYA from


MonoGame is an open source implementation of Microsoft's XNA platform. The goal when developing games using this framework is an additional way to create games and applications for iOS, Android, and Windows Phone 8; Mac OS X, Linux, and Windows 8; and OUYA and PlayStation. The official documentation for OUYA can be found at developers/docs/mono-game. Download the examples for OUYA from

[ 15 ]



Unity3D is a platform game engine that works as a development environment that supports OUYA. In the web console, developers can find documentation on how to prepare Unity to work with the console, and the ODK includes the files needed to integrate Unity with OUYA libraries. We also have to consider that programming for Unity is based on scripting, and for that we can use UnityScript languages such as C# or Boo. Among the engine options for video games development, Unity3D has the highest quality and technical support. In addition to the many applications, development kits, and source code that the Asset Store has, it can also be used to get useful material for projects and development on multiple platforms. Unity3D is available as a development platform for the Windows and Mac operating systems, and allows you to create games for Windows, iOS, Linux, Xbox 360, PlayStation 3, Wii, Wii U, iPad, iPhone, Android, and OUYA (actually). Thanks to the Web plugin that comes with Unity3D, you can also develop games for Windows and Mac browsers. In the following chapters, we will walk you through the process of downloading and installing Unity3D for creating the practice applications and examples mentioned in this book. Download the Unity3D software from The official documentation for OUYA can be found at developers/docs/unity. Download the examples for OUYA from


In this chapter, we learned how to start a new project, the technical specifications of the console (hardware and software), the contents that are not allowed to be published on the console, and the main development tools that are currently available in the market. Also, we mentioned the key applications and online platforms that are currently available on the console.

[ 16 ]

Setup Prerequisites OUYA is an interesting console for developers because it allows them to use different tools to create their video games. Everything from Java and the Android SDK to the most popular video game engines, such as Unity3D and UDK, can be used with OUYA, as shown in the following diagram: I want to make an OUYA Game Make game using cross-platform tools

Make Android Game

Adobe Air Corona Game Maker MonoGame Unity

Eclipse C++ / Jave Native


OUYA's development tools

Although modern browsers such as Firefox and Chrome automatically download any file in a specific path predetermined by them, we suggest creating a directory where you will download all the necessary installers, for example, C:\installers. We also suggest creating a folder in the root of the hard disk, where all the programs that will be explained in the following sections will be installed. For now, you can create a directory called progs in C:. This chapter explains how to install and configure the prerequisites to prepare the development environment for OUYA. Without this step, it will be very difficult to start a project for the console.

Setup Prerequisites

Installing the Java Runtime

The Java Runtime is the first component that must be installed. It should be downloaded from downloads/index.html. Download the appropriate version for your operating system (Linux, Mac OS, 32-bit Windows, 64-bit Windows) as shown in the following screenshot:

Java download options

The installation process is very simple. Run the downloaded JRE file and follow the instructions using the default options. When finished, restart your computer.

Installing the Android SDK

Android SDK is the software that supplements the development environment for OUYA. Download the SDK from html, making sure to select the appropriate version for your operating system (Linux, 32-bit Windows, 64-bit Windows, or Mac OS).

[ 18 ]

Chapter 2

Android SDK download options

The Android SDK does not require an installer; simply extract the main directory in the directory previously suggested (C:\progs) to facilitate the configuration later. When finished, restart the computer. Navigate to <C:\progs\adt-bundle-windows-xXX-xxxxx> and run the SDK Manager.exe file. Within the SDK Manager, we will install the components that are marked in the following screenshot, that is, Android SDK Tools, Android SDK Platform-tools, and Android SDK Build-tools from Tools; all the options under Android 4.1.2 (API 16); and Android Support Library, Google USB Driver, and Intel x86 Emulator Accelerator (HAXM) from Extras. We suggest that you install the API 16 Version; however, these components are available in the API 17 and API 18 Versions too. If you use Unity3D Version 3.5 or higher, we suggest that you install Rev. 21 of the Android SDK.

[ 19 ]

Setup Prerequisites

The options that should be selected are mentioned in the following list: • Tools • Android 4.1.2 (API 16) • Extras °°

Android Support Library


Google USB Driver


Intel x86 emulator Accelerator (HAXM)

The following screenshot also illustrates where the options are provided:

Configuring the Android SDK

[ 20 ]

Chapter 2

You do not need to delete the other components of the SDK (such as other versions of Android) if you have them installed already. The next step is to set the PATH environment variable of the Windows operating system so the Android SDK components can be referenced from any application and run properly. In Windows, this option can be found by navigating to Control Panel | System | Advanced System Settings. You can edit the path variable as shown in the following screenshot:

Configuring environment variables

In this variable, you must add the following line (if some data already exists, insert a semicolon after the last data; however, we recommend that you write the elements from the beginning): C:\progs\adt-bundle-windows-x86_64-xxxxxxxxx\sdk\tools; C:\progs\ adt-bundle-windows-x86_64-xxxxxxxxx\sdk\platform-tools; C:\progs\ adt-bundle-windows-x86_64-xxxxxxxxx\sdk\buildtools\android-X.X.X [ 21 ]

Setup Prerequisites

Installing the Android NDK

The Android NDK is an additional component that is not mandatorily required for all development environments, but we suggest installing it right now, at the initial stages, for future use. Download the NDK from index.html and select the version that fits your operating system: 32-bit Windows 32-bit, 64-bit Windows, Mac OS, and Linux.

Android NDK download options

You will now have the following file structure:

[ 22 ]

Chapter 2

Directory structure

Installing and configuring Eclipse

The Eclipse IDE is used when you want to program natively with Java and Android SDK, and it can also be used with the NDK via the JNI. So it will be a prerequisite to have the Java Runtime or Java Development Kit (JDK) and the Android SDK installed. Download Eclipse from (the Eclipse Standard 4.3 option or the Eclipse IDE for Java Developers option is a good choice).

Eclipse download options

[ 23 ]

Setup Prerequisites

Android provides an Eclipse plugin called Android Development Tools (ADT) to configure new Android projects. This component must be configured within the Eclipse IDE. To install the plugin in Eclipse, perform the following steps: 1. Navigate to Help | Install New Software. 2. Go to and follow the installer instructions and use the default settings. You must then configure the path where the Android SDK was installed so that the Eclipse IDE can reference it. To do this, navigate to the Preferences menu as shown in the following screenshot:

Configuration of the Android SDK in the Eclipse IDE

After performing the preceding steps, the Eclipse IDE will be ready to create Android projects, which is used to create OUYA video games.

Installing Unity3D

From this point onward, we will use the Unity3D engine for implementing a small game. Download the installer Unity Pro (a trial version for 30 days is available) from the following website:

[ 24 ]

Chapter 2

After you download the file, run the installer and use the default options. After the installation, the program will ask for a Unity3D account. If you do not have one, you can create a new one with your e-mail ID, as shown in the following screenshot:

Configuration (creation) of a Unity3D user account

[ 25 ]

Setup Prerequisites

Configuring the Android SDK in Unity3D To configure the Android SDK in Unity3D, you just need to run Unity3D and configure the path to the Android SDK. To do this, you need to navigate to Edit | Preferences | External Tools | Android SDK Location, as shown in the following screenshot:

Configuration of the Android SDK in Unity3D


By the end of this chapter, you will have installed all the prerequisites to develop a game with OUYA, the Java Runtime or Java Development Kit, Android SDK or NDK, Eclipse, Unity3D Engine, and basic settings in Unity3D. The next chapter will present the second part of the settings required to work with OUYA.

[ 26 ]

Setup Instructions for the OUYA ODK This chapter introduces developers to the first steps of setting up their development environment using the OUYA SDK (ODK) and the configuration of the emulator. Also, for those who already have the physical console, this chapter will explain the initial steps of installing it.

Creating an OUYA account

To enjoy the full experience of the console, you must create a user account on the website of the company, There are two types of accounts: gamer and developer. You can create a gamer account on the OUYA device itself, but you will need to create a developer account on the official OUYA website. For the purposes of this book, you must create a developer account, as that will provide you access to a unique developer code called developer UUID. This code number is used to uniquely identify the developer and is associated with each game released on the console. The data that you enter while making your developer account (credit/debit card number, address, and so on) will be associated with your account. You can use your account to log in to more than one OUYA device.

Setup Instructions for the OUYA ODK

Installing the console

The first step is to open the console package and identify all its components, listed as follows: • The console • A control pad • An HDMI cable • A power cable The next task is to perform the physical installation of the console. To do this, perform the following steps: 1. Connect the console directly to your Internet connection (through the cable LAN or Wi-Fi). 2. Connect the console to your TV and turn it on using the OUYA


3. Switch on the control pad by pressing the key so that it can be recognized by the console (the first time takes some time). 4. Go to MANAGE | NETWORK and configure your Internet connection. It's better and highly recommended to use an Ethernet connection as it is more stable. 5. The first time you run the console, the system performs an automatic update of the operating system. 6. Attach the account you have previously created on the website to the console by navigating to MANAGE | ACCOUNT | USER. 7. If you are creating the account for the first time, enter your credit/debit data by navigating to MANAGE | ACCOUNT | PAYMENTS. 8. Download the games of your interest using the DISCOVER option. The following screenshot shows the steps for a console installation:

[ 28 ]

Chapter 3

Downloading the ODK files

In the previous chapters, we explained the steps to install the prerequisites to prepare the development environment. Now we will install the SDK development for OUYA (the ODK). Download the package from the website at as shown in the following screenshot:

[ 29 ]

Setup Instructions for the OUYA ODK

The latest version of the ODK will be downloaded if you click on the Download ODK button. If you require an earlier version, you can use the following links: • • After downloading the file, unzip the file to the root of the working directory where you installed the Android SDK and Android NDK. We should be left with something like this path: C:\progs\OUYA-ODK.

Setting up the ODK in Windows and Mac OS

If you want to use the emulator, the prerequisites for the Windows and Mac OS operating systems are the same. The following are the list of prerequisites: • Java Runtime or Java Development Kit (JDK) preinstalled • Android SDK and Android NDK preinstalled (Android 4.1 / API 16 with Android Support Library and without Google APIs) • Configure the installation paths of Android and Java in the PATH environment variable Then, you must configure the USB driver as explained in the following section.

For Mac OS

1. Locate the ~/.zprofile .bashrc (or ~/.zprofile.zshrc) file and add the following lines of command to it: export PATH=$PATH:~/android/android-sdk-macosx/tools export PATH=$PATH:~/android/android-sdk-macosx/platform-tools export ANDROID_HOME=~/android/android-sdk-macosx

2. Remember to keep in mind what the installation path of the Android SDK was, and modify the preceding lines of command if necessary to indicate the new location.

[ 30 ]

Chapter 3

3. If you want your OUYA console to be recognized by the operating system, add 0x2836 to the ~/.android/adb_usb.ini file. 4. Connect the console through its USB cable and run the following lines of command: adb kill-server adb devices

After that, your console should appear in the list of available devices.

For Windows

You can find more information on ODK setup, including detailed instructions and videos, at Open the c:\progs\ adt-bundle-windows-x86\sdk\extras\google\usb_ driver\android_winusb.inf file with the Notepad editor or any other text editor (note that it's possible that you may need administrator privileges to edit the file).

Disabling Windows 8 driver signature verification If you are using the Windows 8 operating system, disable driver signature verification. To do this, perform the following steps:

1. Add the following lines of code under the [Google.NTx86] section: ;OUYA Console %SingleAdbInterface% = USB_Install, USB\VID_2836&PID_0010 %CompositeAdbInterface% = USB_Install, USB\VID_2836&PID_0010&MI_01

2. Now, add the following lines of code under the [Google.NTamd64] section: ;OUYA Console %SingleAdbInterface% = USB_Install, USB\VID_2836&PID_0010 %CompositeAdbInterface% = USB_Install, USB\VID_2836&PID_0010&MI_01

3. Save the changes. 4. Connect the console through its USB cable and run the following commands: adb kill-server echo 0x2836 >> "%USERPROFILE%\.android\adb_usb.ini" adb start-server adb devices

[ 31 ]

Setup Instructions for the OUYA ODK

After that, your console should appear in the list of available devices in the Device Manager menu in Windows. It's possible that you may have to perform additional steps such as updating the driver for the device. This is because as soon as you connect it, Windows will try unsuccessfully to install drivers. The complete steps are in the OUYA Windows setup documentation available at developers/docs/setup. After finishing all the steps, you can view the logs generating out of the device. You can do this with the Eclipse tools (LogCat) or using adb on the command line (for more information, visit

The OUYA emulator (Virtual Device) configuration

Before we begin, it is important to clarify that the use of the emulator is optional. It is much better to run games directly on the OUYA because the emulator's performance is generally extremely poor in comparison. The initial steps are to open the Android SDK Manager, execute the Virtual Device Management option, and create a new device. The suggested configuration template for the new device is as follows: • Screen Size (in): This should be 32.0 • Resolution (px): This should be 1920 x 1080 • Sensors and Cameras: This should be disabled • Input: This should be DPad • RAM: This should be 1024 • Size: This should be xlarge • Screen Ratio: This should be long • Density: This should be tvdpi

[ 32 ]

Chapter 3

The following screenshot shows the complete configuration of a Virtual Device:

Recommended configuration settings

[ 33 ]

Setup Instructions for the OUYA ODK

We can create an OUYA emulator with the preceding template. The suggested configuration for the emulator is shown in the following screenshot:

It is important to note that there are several possibilities to set the resolution of an Android Virtual Device, such as its density and size variables. In the following screenshot, we see the various available options:

The Density and Size Screen tables to configure a Virtual Device

[ 34 ]

Chapter 3

Executing the OUYA emulator

The last step is to run the OUYA emulator. For that, the first thing to do is load the Virtual Device created in the previous step from the Android Virtual Devices handler as shown in the following screenshot:

Running the Android Virtual Device

When you load the desktop's Android operating system, the system is ready to run the OUYA emulator. To do this, run the two applications that are within the OUYA-ODK directory (ouya-framework.apk and ouya-launcher.apk). Type in the following lines of commands: adb start-server adb install -r ouya-framework.apk adb install -r ouya-launcher.apk

[ 35 ]

Setup Instructions for the OUYA ODK

The launcher should now appear on the screen. Here, you are presented with two possibilities, the Android application launcher and the application launcher for OUYA. If you select the latter, you can use the OUYA emulator. The following screenshot shows the execution of the OUYA launcher:

From this point, you can install a .apk file on the emulator to see the execution of our own games. To install a game, copy the game's apk file into the root OUYA-ODK directory and then type in the following command: C:\progs\OUYA-ODK\adb install your_demo_game.apk


By the end of this chapter, you should have the environment ready to deploy your first project for OUYA, that is, the OUYA SDK (ODK) and the console emulator. The next chapter will explain the use of OUYA Development Kit (ODK).

[ 36 ]

Guidelines for Setting Up the OUYA ODK This chapter will explain the various resources, folders, and libraries in the ODK, and the code that needs to be created to initiate a project for the OUYA console.

Starting with the OUYA Development Kit

The OUYA Development Kit (OUYA ODK) is a tool to create games and applications for the OUYA console, and its extensions and libraries are in the .jar format. It is released under Apache License Version 2.0. The OUYA ODK contains the following folders: • Licenses: The SDK games and applications depend on various open source libraries. This folder contains all the necessary authorizations for the successful compilation and publication of the project in the OUYA console or testing in the emulator. • Samples: This folder has some scene examples, which help to show users how to use the Standard Development Kit. • Javadoc: This folder contains the documentation of Java classes, methods, and libraries. • Libs: This folder contains the .jar files for the OUYA Java classes and their dependencies for the development of applications for the OUYA console. • OUYA Framework APK file: This file contains the core of the OUYA software environment that allows visualization of a project based on the environment of OUYA. • OUYA Launcher APK file: This file contains the OUYA launcher that displays the generated .apk file.

Guidelines for Setting Up the OUYA ODK

The ODK plugin within Unity3D

Download the Unity3D plugin for OUYA. In the developer portal, you will find these resources at After downloading the ODK plugin, unzip the file in the desktop and import the ODK plugin for the Unity3D folder in the interface engine of the Assets folder; you will find several folders in it, including the following ones: • Ouya: This folder contains the Examples, SDK, and StarterKit folders • LitJson: This folder contains libraries that are important for compilation • Plugins: This folder contains the Android folder, which is required for mobile projects

"The Last Maya" created with the .ngui extension

Importing the ODK plugin within Unity3D

The OUYA Unity plugin can be imported into the Unity IDE. Navigate to Assets | Import Package | Custom Package…. Find the Ouya Unity Plugin folder on the desktop and import all the files. The package is divided into Core and Examples. The Core folder contains the OUYA panel and all the code for the construction of a project for the console. The Core and Examples folders can be used as individual packages and exported from the menu, as shown in the following screenshot:

[ 38 ]

Chapter 4

A complete documentation on the ODK plugin for Unity3D can be found at

Installing and configuring the ODK plugin

First, execute the Unity3D application and navigate to File | Open Project and then select the folder where you need to put the OUYA Unity plugin. You can check if Ouya Unity Plugin has been successfully imported by having a look at the window menu at the top of Unity3D, where the toolbars are located. In this manner, you can review the various components of the OUYA panel. While loading the OUYA panel, a window will be displayed with the following sections and buttons: • Build Application: This is the first button and is used to compile, build, and create an Android Application Package file (APK) • Build and Run Application: This is the next button and allows you to compile the application, generate an APK, and then run it on the emulator or publish directly to a device connected to the computer • Compile: This button compiles the entire solution The lower section displays the paths of different libraries. Before it uses the OUYA plugin, the user ought to edit the fields in the PlayerSettings window (specifically the Bundle Identifier field), set the Minimum API Level field to API level 16, and set the Default Orientation field to Landscape Left. Another button that is mandatory is Bundle Identifier synchronizer, which synchronizes the Android manifest file (XML) and the identifiers of Java packages. Remember that the package ID must be unique for each game and has to be edited to avoid synchronization problems.

[ 39 ]

Guidelines for Setting Up the OUYA ODK

Also, the OuyaGameObject (shown in the following screenshot) is very important for use in in-app purchases:

The OUYA panel

The Unity tab in the OUYA panel shows the path of the Unity JAR file, which houses the file's JAR class. This file is important because it is the one that communicates with the Unity Web Player. This Unity tab is shown in the following screenshot:

[ 40 ]

Chapter 4

The Java JDK tab shows the routes of the Java Runtime installation with all its different components to properly compile a project for Android and OUYA, as shown in the following screenshot:

The Android SDK tab displays the current version of the SDK and contains the paths of the different components of the SDK: Android Jar Path ADB, APT SDK Path, and Path, as shown in the following screenshot. These paths must correspond to the PATH environment variable of the operating system.

[ 41 ]

Guidelines for Setting Up the OUYA ODK

Finally, the last tab of the OUYA panel, Android NDK, shows the installation path of C++ scripts for native builds, as shown in the following screenshot:

Installing and configuring the Java class

If at this point you want to perform native development using the NDK or have problems opening or compiling the OUYA project, you need to configure the Java files. To install and configure the Java class, perform the following steps: 1. Download and install the JDK 1.6 and configure the Java Runtime path in the PATH environment variable. 2. Next, you need to set a unique bundle, gametitle. 3. Hit the Sync button so your packages and manifest match. 4. Create a game in the developer portal that uses the bundle ID. Download that signing key (key.der) and save it in Unity. 5. Compile the Java plugin and the Java application. 6. Input your developer UUID from the developer portal into the OuyaGameObject in the scene.

Identifying the user

Every developer who wants to create an application for OUYA needs a unique identification number, called the UUID code. It allows access to the application development API and real-time purchasing system on the console. In any OUYA project, include this number in the source code to be properly identified in the OUYA marketplace and prevent fraud. [ 42 ]

Chapter 4

You can find your UUID code on the main page of the OUYA developer portal ( after you log in. The UUID code has a structure similar to the following one: 00000000-0000-0000-0000-000000000000 An example UUID code is shown in the following screenshot:

Once you have a developer ID, you must include it within the OuyaSDK.cs and ouyaInputHandler.cs scripts as shown in the following screenshot. This will allow you to access the purchasing system on the console.

UUID code (OuyaInputHandler)

[ 43 ]

Guidelines for Setting Up the OUYA ODK

Starter kit – examples

The ODK plugin for Unity3D contains the following four scenes: • Initial scene • Welcome scene • Main menu scene • Game scene The preceding scenes are shown in the following screenshot:

The Unity/OUYA Starter kit

[ 44 ]

Chapter 4

You will find the following three main files inside the Scenes folder: • SceneInit.Unity: This is the application file that runs at the beginning • SceneSplash.Unity: This is the scene showing the title or cover of the game • SceneMain.Unity: This is the main game scene The initial scene contains the OuyaGameObject script. This script allows the welcome scene to load. The main scene is associated with a GUI button that allows the game to load.

Common errors while working with OUYA In the next section, we'll be covering some errors that are commonly encountered while working on the OUYA system.

Errors with the emulator

The configuration of the emulator with an optimal resolution is one of the greatest hurdles to overcome before we can begin testing with our APK. One of the first steps to avoid errors is to correctly configure the paths for the Android SDK and the Java Runtime, and include them in the PATH environment variable of your operating system.

[ 45 ]

Guidelines for Setting Up the OUYA ODK

Additionally, you need to install the Intel x86 Atom System package within the Android SDK.

Install Intel x86 Atom System package

It is important to remember that the use of a non-Intel processor for the various tests can affect emulator screen resolutions and configuration processes. This virtualization of Android hardware makes the emulator run much faster, but it is only available to you if you have an Intel CPU.

Errors with Eclipse

If you use the Eclipse IDE, a typical error is generated during Java configuration. To resolve this problem, install the 32-bit version of the Java Runtime.

[ 46 ]

Chapter 4

Errors with the ADB connection USB

There should be no carriage return after the hex value. Any blank lines in this file will result in an error. Add ~/ to android/adb_usb.ini. Create the adb_usb.ini file if it doesn't exist so your OUYA console can be recognized, and then insert the following command: 0x2836

Errors in the OUYA panel

When opening the OUYA panel window, you may receive the Mismatched Bundle Error. It appears because of issues in the synchronization of paths. To correct this error, click on the Sync Bundle ID button. The error will disappear after a few seconds. Other errors may occur when compiling Android from Unity. To correct this, you can download the 32-bit version of the Java Runtime at the following link (this alternative procedure can only be used in the Windows platform):


In this chapter, we explained the most important ODK plugin settings for Unity3D as well as the importance of using the UUID identification code developed for the OUYA project. Integrating the UUID code with your code in order to implement in-game purchases will be covered later in the book. We also identified the most common mistakes when working on the development environment for OUYA. In the next chapter, we will elaborate on the project: configuration of controllers, compilation, and execution of the video game.

[ 47 ]

Configuring the Controllers This chapter will assess the main features of the buttons for the controls and the hardware for the OUYA console.

The OUYA Controller

The control pad has the following features: • It is a 2.4 GHz RF wireless controller and a standard Bluetooth controller • Two (2) AA batteries for each controller • A touchpad that works like a mouse • Four digital buttons (O, U, Y, and A) • A directional pad (D-Pad) that supports four direction buttons • Two analog sticks (LS and RS) • Two digital buttons that activate when the analog sticks are pushed straight down (L3 and R3) • Two shoulder buttons (L1 and R1) • Two analog triggers (L2 and R2)

Configuring the Controllers

â&#x20AC;˘ The OUYA (U) button (used to bring you back to the OUYA main menu).

A description of buttons

Setting the controls

For this book, we will use a limited version of "The Last Maya" as our game is about the actual origin of Maya culture. The Assets folder of Project Unity contains 3D models that include pyramids, characters, scripts, and the main scene maya.unity. If you purchase this book, all these resources will be present in the code bundle, in the file. Open and unzip the project, including Asset/maya, and open the main stage by double-clicking on the maya. unity file. The purpose of using the OUYA framework is to have an input access tool that allows multiple drivers for multiple controls. It should be clarified that this is the Ouya SDK + Unity plugin, and not the OUYA input framework.

[ 50 ]

Chapter 5

To change the settings in our scene, you need to use the OuyaInputHandler.cs script and the InputManager.asset file. To do this, you need to execute the following steps: 1. Copy the InputManager.asset file to the ProjectSetting folder of your project. In this section, it is very important to check the variables present in the OuyaInputManager.cs file with the configuration of the buttons. This will overwrite any custom changes to the input preferences. 2. Copy the OuyaInputHandlerExample.cs file to the Scripts folder, which is located in the Asset/Ouya/Example/Scripts directory, and rename the script as OuyaInputHandler.cs. 3. Place the OuyaGameObject.cs script in the opening scene that is in the Asset/Ouya/SDK folder and write your developer UUID in the beginning of the section. The SDK comes with an OuyaGameObject prefab, and the developer ID can be set using the inspector of Unity. 4. Another optional script is OuyaInputTest.cs, which is useful for connecting any OuyaGameObject with the GUI's interaction. If not required in your project, you can remove the OuyaInputTest.cs script from the Scripts folder.

Creating the first scene of the game

In the project that is open, it identifies the entire directory structure, including the OUYA SDK directory structure, NGUI, and The Last Maya files.

The folder's project structure

[ 51 ]

Configuring the Controllers

Inside the mayan directory, you will find all of the main 3D objects of the project: pyramids, oracle, animations, and the main character.

3D models of The Last Maya file

Next, to ensure that our character can move around within the scene, perform the following steps: 1. Insert a terrain in the scene and our character can collide with this terrain. This allows the character to interact with what is basically the "ground" of the scene. Another option could be to add a floor (plane) that interacts with the character. 2. Add a light to the scene. This light allows the player to see the details of the imported models. The light source is needed to illuminate the objects that are present in the scene. 3. Select the main mayan character on the hierarchy window with the F key on the keyboard. Find it in the "script third person" controller contained in the Standard Assets folder and drag the script to the character. 4. The Maya.unity project contains Standard Assets/Character Controllers assets by default. Make sure the controller (the green cylinder) covers the whole body of the character. 5. Click on the Project window and place yourself in Standard Assets/ Character Controllers and drag the "third person" code to our character imported as maya.unitypackage. 6. Remove any other camera in the scene and only use the camera that is associated with the character. This camera allows you to incorporate the coordinate axes (X, Y, and Z) to our character. [ 52 ]

Chapter 5

A character imported in the scene would look like what is shown in the following screenshot:

The character has six basic animations that can be seen from the inspector's window of Unity3D. These are walk, run, stand, idle, active, and attack. Each of these animations must be configured in the OuyaInputHandler.cs file linked to a button. It uses the legacy animation system in Unity. You can find the animations in the mayan folder and drag them to the controller script that appears in the project window section. Each animation contains a logical sequence of frames linked to the character.

Character animations

[ 53 ]

Configuring the Controllers

The character must contain the character controller scripts and have associated the OuyaInputHandler.cs file (refer to the following screenshot):

Assigning the scripts for a character's controller

To ensure that the character can move through the scenario, you need to locate the controller script in the positions of the X, Y, and Z axes, completely covering the 3D model of the character. It is also necessary for the controller script to be integrated with the OuyaInputHandler.cs file.

Assigning the OUYA controls

The primary code to be amended is present in the OuyaInputManager.cs file where you put the developer UUID and the OuyaInputHandler file, which sets the coordinates and animations of the Ouya control buttons. For this purpose, we must consider the elements of conventions regarding the joystick and D-pad: the top axis is positive (+) and down axis is negative (-). Additionally, the right axis is positive (+) and the left is negative (-).

[ 54 ]

Chapter 5

In OUYA's analog command, the X and Y values are generated in the range of -1 to +1 with zero being neutral.

The axis joystick and D-pad

The next step is to configure animations and buttons for the character. Before proceeding, we must consider the state of the button. Each button calls OUYA's control animations such as walk or run. For the following example, the run and idle animations are observed in detail in the Update() function of the OuyaInputHandler.cs script, linked to the character, as shown in the following code: //ATTACK STANCE: if (b.Equals(OuyaSDK.KeyEnum.BUTTON_Y) && bs.Equals(OuyaSDK. InputAction.KeyDown)) { if (!isBattleStance) { //Set Battle stance. this.animation.Play("idle"); isBattleStance = true; } else { if (this.animation.IsPlaying("attack_1")) {

[ 55 ]

Configuring the Controllers this.animation.Play("idle"); isBattleStance = false; } } } //ATTACK: if (b.Equals(OuyaSDK.KeyEnum.BUTTON_U) && bs.Equals(OuyaSDK. InputAction.KeyDown)) { this.animation.Play("attack_1"); } //RUN: if (b.Equals(OuyaSDK.KeyEnum.BUTTON_Y) && bs.Equals(OuyaSDK. InputAction.KeyDown)) { this.animation.Play("run"); } //FAKE READY: if (b.Equals(OuyaSDK.KeyEnum.BUTTON_A) && bs.Equals(OuyaSDK. InputAction.KeyDown)) { this.animation.Play("ready"); } }

The menu or system button

The SDK includes interfaces for the OUYA menu button. To use the menu or system OUYA button (U), remember to press the menu button twice or press and hold it to go back to OuyaController.Button_menu. A single press will now send an OuyaController.BUTTON_MENU (KEYCODE_MENU) keycode to the app, emulating a normal menu button. To bring up the system menu, you may now tap the OUYA button twice or press the OUYA buttons on newer controllers for a long time. When the system button is pressed, the pause menu will be shown: public void OuyaMenuButtonUp() { // your code here }

[ 56 ]

Chapter 5

The menu or system button

Differences between an analog joystick and a touchpad Both the analog stick and the touchpad use the OnGenericMotionEvent event to report a state. To differentiate them, we must assess the input source. In order to assess the input source, we query the InputDevice class. Depending on the value returned, we can tell if the input is provided by the joystick or the touchpad. The values returned for the specific device are shown as follows: Joystick == InputDevice.SOURCE_CLASS_JOYSTICK Touchpad == InputDevice.SOURCE_CLASS_POINTER

This querying can be illustrated with the following example: @Override public boolean onGenericMotionEvent(final MotionEvent event) { //Get the player event int player = OuyaController.getPlayerNumByDeviceId(event. getDeviceId()); //Joystick if((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) { float LS_X = event.getAxisValue(OuyaController.AXIS_LS_X);

[ 57 ]

Configuring the Controllers //do other things with joystick } //Touchpad if((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { //Print the pixel coordinates of the cursor Log.i("Touchpad", "Cursor X: " + event.getX() + "Cursor Y: " + event.getY()); } return true; }

The difference between using the analog stick and the touchpad is the level of sensitivity and the degrees of freedom for the controls. The joystick is efficient for 3D games and the touchpad is not good for 2D gaming; it is more like using a mouse pointing device. In general, using the touchpad to control a character is more difficult than using the analog stick. It is a great feature that can be used to great effect in the right context, but it needs to be implemented with care.

Testing changes in the state of the button

There is a function within the script that detects when a button is pressed or released, so it can process its current state. The following is the first section of code that shows the state of the button in use, that is, when an action is executed: if (c.buttonChangedThisFrame(OuyaController.BUTTON_O)) { if (c.buttonPressedThisFrame(OuyaController.BUTTON_O)) { Execute_Action();

The second part of the code (the action is suspended) is as follows: } else if (c.buttonReleasedThisFrame(OuyaController.BUTTON_O) { End_Action(); } }

The OuyaController class contains OUYA-specific constants for buttons and axes. A small selection is shown in the following code: public public public public

static static static static

final final final final

int int int int


Chapter 5

The following are the three basic events to check the status of the onKeyDown, onKeyUp, or onGenericMotionEvent buttons: @Override public boolean onKeyDown(int keyCode, KeyEvent event) { boolean handled = OuyaController.onKeyDown(keyCode, event); return handled || super.onKeyDown(keyCode, event); } @Override public boolean onKeyUp(int keyCode, KeyEvent event) { boolean handled = OuyaController.onKeyUp(keyCode, event); return handled || super.onKeyUp(keyCode, event); } @Override public boolean onGenericMotionEvent(MotionEvent event) { boolean handled = OuyaController.onGenericMotionEvent(event); return handled || super.onGenericMotionEvent(event); }

Once OuyaController gets the events, you can then get an instance of the class by using the device ID or player number, as shown in the following code: OuyaController c = OuyaController.getControllerByDeviceId(deviceId); OuyaController c = OuyaController.getControllerByPlayer(playerNum);

It is a good practice to clear the input state when the scene loads and when it is destroyed, as shown in the following code: void Awake() { Input.ResetInputAxes(); } void OnDestroy() { Input.ResetInputAxes(); }

When a controller connects or disconnects, a calibration event will be fired, as shown in the following code: public void OuyaOnJoystickCalibration() { // your code here } [ 59 ]

Configuring the Controllers

For the button input, the examples use the following: OuyaExampleCommon.GetButton (GetButton, GetButtonDown, GetButtonUp)

For the axis input, the examples use the following: OuyaExampleCommon.GetAxis (GetAxis, GetAxisRaw)

Compiling and executing the game

To compile the game, we must incorporate the game scenes in the Build Settings window. The SceneInit starter Kit (level 0) and Maya are the scenes that correspond to the game (level 1), as shown in the following screenshot:

Setting up Build Settings

We name our APK file THE_LAST_MAYA, select Android as the platform, and set 16 as the Minimum API level value by allowing correct compilation. The other parameters in the Player Settings window are set by default. They are important because OUYA has input preferences for default values. The following fields need to be filled in the Identification section: • Bundle Identifier: This is the project name. • Bundle Version: By default, it is 1.0. • Minimun API Level: Select API level 16, which corresponds to Android 4.1. This is the minimum version that supports OUYA.

[ 60 ]

Chapter 5

The following are the fields to be filled in the Configuration section: • Device Filter: Select only ARMv7 (this is the recommended option for OUYA) • Install Location: Select Prefer External (this is the recommended option for OUYA) • Graphics Level: Select Open GL ES 2.0 (this is the recommended option for OUYA)

Settings for Android

And finally, we click on the Build section in the Build Settings window, to start the compilation. [ 61 ]

Configuring the Controllers


This chapter covered the initial steps to optimize the development of a project's scenes, the basic controls, and how to set up the coordinates. The compilation of the game for Android and the OUYA console was also covered. In the next chapter, you will learn all about making money with your game using the OUYA marketplace.

[ 62 ]

The OUYA Marketplace This chapter shows us all the steps to set up an account and allow users to buy video games and other in-game inventory items, such as extra levels, weapons, and power-ups.

Update your user profile

It is possible that you might have left some fields incomplete when you created your user account. It is time to complete them so that the store can work correctly. Navigate to the OUYA portal to edit your details. Enter the address as https:// in the browser, after which the following screenshot will appear:

The developer's profile information

The OUYA Marketplace

In order to upload your video game to the OUYA store, you must complete the following sections: • Developer Profile • Marketplace Agreement In order to sell your products, you must complete the following sections: • Payment Info • Tax Documents Navigate to to update the information, as shown in the following screenshot:

User profile form

In the payment information section, you should include all the details of your bank account, including the full name of the bank, SWIFT code, and IBAN or account number. The tax information is supported by a form that you must fill according to your country.

[ 64 ]

Chapter 6

If you are a resident of the U.S.A, you must fill the IRS Form W-9 form. If you live in a different country, you must complete the IRS Form W-8BEN form. After filling the form, you must scan it, convert it to the PDF format, and upload it to the page. The PDF file has a maximum size of 2 MB, as shown in the following screenshot:

The payment and tax information

Configuring the items of purchase

The second step is to create all the in-game purchase items that we wish to sell within our games. In order to do this, we must visit the developer portal and click on Products. This link will take you to another page where you will use the New Products link to create all the items that are to be sold in our various games. The link to the developer portal is Make sure that you create a code snippet and description for each product, which allows the product to be identified and associated with the specific game that it belongs to.

[ 65 ]

The OUYA Marketplace

Each product has a unique identification code, a description or name of the product, price, and product type. The code can be composed of letters, numbers, and underscores. The product description provides further details on what the product does. It is suggested that you indicate the product name and the game to which it belongs as part of the product description, in order to prevent future errors when your inventory of products is very large. The price starts at $0.99 and you can select the desired value. The Type field has the following two options: â&#x20AC;˘ Entitlement: This type of product is used to give a user the right to buy a video game or unlock levels. It is used only once, after which the game or level is permanently unlocked. â&#x20AC;˘ Consumable: This type of product is used for items such as coins and powers. These can be purchased multiple times.

The form used to create a product

[ 66 ]

Chapter 6

The preceding operation is repeated for each item that is to be sold, in order to finish creating all the inventory items that are on sale. The portal will display all the products; this can be edited as required. All fields except the product identifier are editable. The Price field and the Type field are very important, because they are the basis for the monetization of the video games.

In each sale, the OUYA store keeps 30 percent of the profit. The developer will receive the first payment when they have collected at least $150 and payments are made after every 30 days. Once you create a product, it cannot be removed. It should be noted that for testing purposes, any purchases made by the account that created the game will not be charged. This is imported if you are testing with more than one account.

Creating a game in the OUYA store

To begin receiving payments from the sales of the inventory or unlock levels, you need to create a video game by using your developer account and associating the products to the game. Take a look at the following screenshot:

Creating a new game

[ 67 ]

The OUYA Marketplace

It is important to have some pictures of what our game looks like so that they can be published on the OUYA server, as shown in the following screenshot:

Creating the Key.der file

It is not enough to just create all the purchasable items and the video games in the OUYA store. You also need to download an encrypted code associated with each game that is published on your account. This code is in the Key.der file, as shown in the following screenshot:

[ 68 ]

Chapter 6

View of a game created with the link to download the Key.der file

To download the Key.der file, you need to click on the Download link in the My Games page and save it on your hard drive. The inside view of the Key.der file is a set of encrypted code that generates the link between our program and the OUYA store to allow it to make a purchase. The project has a Key.der file and this must be replaced with the downloaded file from your user account.

Programming access to the marketplace

The OUYA SDK provides us with the ability to use a script to quickly configure our interface for shopping. You need to install a script into Unity3D. To see it in practice, you must go to the following path and import the respective script: Assets/OUYA/examples/scenes/OuyaShowProducts.unity

[ 69 ]

The OUYA Marketplace

The ShowProducts.cs script shows us how to get details about the items that can be purchased from the OUYA store. Open the scene by double-clicking on the OuyaShowproducts.unity file, as shown in the following screenshot:

Using the ShowProducts script

The publishing portal also allows our games to be customized, including specifying which countries will be allowed or denied access to our video game. The game must meet specific requirements that define the company's OUYA and are posted on the developer's website.

A general guide to OUYA game content In general, the following recommendations should be taken into account before releasing a video game on the OUYA console:

â&#x20AC;˘ Safe zone: This is a margin to be taken into account on all the edges of a screen to avoid problems when viewing the application on a TV. â&#x20AC;˘ Prohibited content: Make sure that the game does not promote violence; does not contain explicit sexual content; or does not promote hatred towards a person or group of people for their race or ethnicity, religion, disability, sex, age, veteran status, or sexual orientation/gender identity.

[ 70 ]

Chapter 6

• Gameplay: The game should be playable without being connected to the Internet and should not require any additional hardware or software. • Shopping: The In-App Purchase API must be used for purchases and sales. • OUYA Content Ratings: To rate a game, the following scale should be used: everyone, ages 9 and higher, 12 and higher, and 17 and higher. • App's images and icons: Each game or application needs icons and image resources that help us customize the look and feel of the game. Icons are used to customize the shortcut that launches the game. °°

The application's image path is Assets\Plugins\Android\res\


and the image size must be 732 x 412 °°

The application's icon path is Assets\Plugins\Android\res\ Assets\Plugins\Android\res\drawable\app_icon.png, and the image size must be 96 x 96

More information is available at content-review-guidelines.

Build settings

To compile the video game within the Unity3D program, perform the following steps: 1. Inside the Scenes folder, you will find the following three main files of THE LAST MAYA video game: °°

SetUp.Unity: This is the file application that runs in the beginning


TitleScreen.Unity: This is the scene that shows us the title or


GameScreen.Unity: This is the main game scene

cover of the game

2. First, navigate to the Assets\Scenes folder and drag the following files to the box labeled Scenes In Build, in the following order: °°

SetUp.Unity (stay with consecutive number 0)


TitleScreen.Unity (stay with consecutive number 1)


GameScreen.Unity (stay with the consecutive number 2)

The three files should be selected. If the numbers are not consecutive in the preceding order, delete the files in the window (check each file and press the Delete key) and repeat the process.

[ 71 ]

The OUYA Marketplace

3. Secondly, in the PlayerSettings window, set the following parameters, as shown in the following screenshot: 째째

Company Name: your_company (for example, inHouseLabs)


Product Name: your_product_name (for example, THE_LAST_MAYA)

The Build Settings window

Testing the project with the emulator

Load the Android SDK and run the Android Virtual Device for OUYA's emulator. Next, run the ouya-framework.apk and ouya-launcher.apk applications that are within the OUYA-ODK directory. Type the following commands in a console or a terminal: adb install -r ouya-framework.apk adb install -r ouya-launcher.apk

[ 72 ]

Chapter 6

Next, go to the ouya_mayan/apk folder, and run the following command to load the video game: adb install -r ouya_mayan.apk

After executing the preceding command, the following screenshot will appear:

Running OUYA's emulator


After reading this chapter, you will possess the ability to set up your account to receive money from the sales of your products and video games. Also, use the main features to process purchases such as the product creation, creating a game, and creating the Key.der encrypted file.

[ 73 ]

Advanced OUYA Functions â&#x20AC;&#x201C; Graphics and Controls This chapter assesses the essential tools needed to manage multiple controllers and shaders for the graphical optimization of the OUYA console. This chapter allows you to learn more about the tools for the use of multiple controllers and graphical optimization with shaders, and gives an introduction to lighting on the OUYA console.

Basic materials

Advanced OUYA Functions â&#x20AC;&#x201C; Graphics and Controls

A shader is code that is executed on the Graphics Processing Unit (GPU), usually found with a graphic card. Shaders are applied to create rendering effects such as fire, lights, and toon effects. Shaders are simple programs that transform a vertex or a pixel to manipulate the textures and lighting of a material or surface. You can use them whenever you want to generate or manipulate lighting effects on textures and materials. You can use different programming languages to write a shader, from high-level programming languages such as C, to low-level languages such as assembly languages. The shader is a programming script that is used to produce appropriate levels of light and color in an image. Depending on the type of API that is used by the video game engine, you will get intermediate or advanced scenes with lightmapping and global illumination. Some issues that need to be taken into consideration to optimize shader performance are reducing the amount of particles and increasing the opacity of materials by using textures creatively. Remember that the OUYA console supports a resolution of 720p or 1080p output only. More information on this can be found at http://docs.

Understanding shaders

A shader is used to perform graphics transformations and create special effects such as lighting, lenses, lights, water, fire, fog, or particle systems. A shader integrated in Unity3D would look as follows:

[ 76 ]

Chapter 7

The following are the prerequisites to obtain optimal knowledge of shaders and use them properly: • Scripting functions, classes, and variables • A NextGen game, which is a very expensive cost render that accepts diffuse, specular, diffuse, emissive, and parallax • Cartoon games have a very low-cost render that accepts only diffuse • A basic knowledge of mathematics, especially quadratic functions and transformational math, in short, basic linear algebra • Trigonometric calculations to calculate the intensity of environmental light • All the textures we load have to be powers of 2, such as 64 x 64, 128 x 64, and many others The use of shaders needs a language that is created for it. The use of shaders is based on languages such as ShaderLab, GLSL, and CG. The Tegra processor of OUYA allows several shaders with languages such as Boo, JavaScript, or Microsoft Visual C#. Some of the languages are explained as follows: • ShaderLab: This is the shader language at the core of Unity3D, and is required by all shaders. It is a very basic language. • CG: This is a shader language developed by Nvidia. It is powerful and an easy language to learn. The CG shader is the most widely used shader in Unity3D because it uses a high-level programming language. • GLSL: This is a shader language that is used for mobile devices; it is a basic language and is very similar to the CG shader language. The process of loading the texture memory, OpenGL is not like. Algorithms to implement lighting with shaders are based on powers of 2, for example, 64 x 64 and 1024 x 1024. To create shaders, navigate to Assets | Create | Shader of menubar in Unity. The shader can be edited by doubling-clicking on the Project view. The following is a structure that represents a basic shader: Shader "Tutorial/Basic" { Properties { _Color ("Main Color", Color) = (1,0.5,0.5,1) } SubShader { Pass { Material {

[ 77 ]

Advanced OUYA Functions – Graphics and Controls Diffuse [_Color] } Lighting On } } }

The algorithm allows us to use several shaders, assets, items, and characters in the game scene. The following parameters of the angles of light should be modified: • Transparency application • Light reflectivity • Filtering application

Types of shader processors

The programmer sends a set of vertices to form the scene graph. All vertices are processed by a vertex shader where they can be transformed. This vertex also determines their texture mapping. Texture mapping can be summarized with the following three characteristics: • It loads an image and is defined as a texture • It indicates how the texture is applied to each pixel of the surface • It indicates the correspondence between the coordinates It produces a level of color that changes according to the proximity of the illuminated objects. The geometry shader's vertices can be deleted or added. Finally, the vertices are assembled into primitives that are tracked, that is, they are transformed into pixels on the graphic display. The pixel shaders receive individual pixels and perform calculations on them to determine things such as color and lighting. The vertex or fragment shader is responsible for modifying these points in depth, and that creates a high-quality image. Fragment and pixel shaders have the same principle. It is also used by the Tegra 3 processor, OUYA's graphics processor, which that performs the optimization process while rendering the game scene.

[ 78 ]

Chapter 7

Shader processors

To understand more about different shaders, it is necessary to know the differences with regard to the structure and complexity. The shaders are explained as follows: • Vertex shaders: This shader's programming is simple; it uses the C language. It modifies the vertex position and color and textures coordinates. It gets information about the vextex and is responsible for transforming its coordinates, texture coordinates, normal, and many other parameters. • Vertex/fragment shaders: These shaders are a little more complex because they divide 3D models according to the intensity scales of a color. These shaders are more complex to code and then calculate the color of individual pixels. They are more complete, but highly editable. Note that Direct X refers to them as pixel shaders, and Open GL calls these fragment shaders. You can get the information associated with each pixel occupied by the geometry of a model on the screen; this is responsible for the final color. • Fixed function: This is usually used in devices that have limitations of pixels or low capacity. This is written entirely in ShaderLab, and is used in older devices. To observe the real difference between the shaders in our scene, it should be understood that the post-effects are variable. You can only see the shaders in the Unity3D Professional version or the 30-day trial version of the game engine offered by the company. The shader assembly language code can only be opened and viewed using Unity Professional.

[ 79 ]

Advanced OUYA Functions – Graphics and Controls

The following screenshot shows lighting without the CG shader and without using SSOA (the occlusion system). The part to the left shows the standard shader and the part to the right shows the shader using the Unity3D Professional version.

To optimize our models and increase performance, we should take into account materials, assets, and items (meshes). We also need to consider the following tips: • Do not leave too many small objects in the scene; it is better to combine them and create a single object • Do not combine objects that are far away, because when the camera sees the corner of one, it will rebuild all the objects • If you have an object that has multiple materials, it is best not to combine them, as it will reduce performance

The CG programming language for Nvidia Tegra 3

C for Graphics (CG) is a high-level shading language developed by Nvidia in close collaboration with Microsoft, to program vertex and pixel shaders. CG is based on the C programming language and they both share the same syntax. The following is a sample CG vertex shader:

[ 80 ]

Chapter 7

Characteristics of the Tegra 3 processor

The Tegra 3 processor is a mobile multicore processor from Nvidia, used in the OUYA console. It has the following characteristics: • Supports Physics-based shaders for natural projection of light. It also contains functions to allow the manipulation of transparency and opacity of objects. • Reflection shaders to be used in effects of particles. • Combining normal maps for improving the graphical quality. • Optimization of polygons reduces the size of the game. • Optimizes global illumination and generates environments that are more realistic. • Ambient occlusion. • Skin rendering. Visit to download shaders for Unity3D.

[ 81 ]

Advanced OUYA Functions – Graphics and Controls


The lighting of a scene is very important because the 3D models can interact to produce simple or double light sources or light probes that produce different lighting intensities in the game. For global illumination in the 3D engine, it is necessary to save the scene with the 3D models and light sources as static components. The 3D models and lights are static components because they don't have any Physics that generate movement. This means that static game objects do not interact with PhysX. Remember that Unity3D uses the following application programming interfaces: • Windows Direct x11 • Open GL on Mac and Linux • Open GL-ES on Android and iOS The steps to set up the lighting feature in Unity are as follows: 1. Open the maya.unity scene located in the Assets folder. To use lightmapping in our maya.unity scene, select the toolbar and select the Unity3D path in the tool panel by navigating to Window | Lightmapping. Unity3D integrates lightmaps and advanced illuminations for online game and mobile device design.

[ 82 ]

Chapter 7

2. Immediately, you will see a window with three sections (Object, Bake, and Maps). Unity3D has an integrated lightmapper named Beast Lightmap. You can create global illumination maps covering lights and shadows of the scene models from the Unity3D IDE, thus increasing performance. The values of the Final GatherRays and Resolution parameters in the Bake section are 200 and 10 respectively, as shown in the following screenshot:

[ 83 ]

Advanced OUYA Functions â&#x20AC;&#x201C; Graphics and Controls

3. Then we click on Bake and generate our lightmapping after a few minutes (the time taken depends on the number of 3D models). The map of lights and shadows will be created by Unity3D for all scenes. 4. The lightmapping's results depend on the reproduction routes. To modify them without having to retake the lightmapping for the whole scene, you should navigate to File | Build Settings | Player Settings | Other Settings. Make the appropriate changes to the player setting and the main camera, as shown in the following screenshot:

Ligthmapping player settings

It is necessary to take into account aspects such as lights and lightmaps, so keep the following things in mind: â&#x20AC;˘ Do not use more than one light with shadows Dynamics by scene.

[ 84 ]

Chapter 7

â&#x20AC;˘ By using light probes, we can optimize the game scene and make the scenes more realistic. You can add light probes to any object in the scene (by navigating to Component | Rendering | Light Probe Group). The light probes appear as yellow spheres that can be positioned in the same manner as the game object, as shown in the following screenshot:

Draw Calls is a tool that improves the graphic quality of a video game. More information on lightmapping is available on the official website of Unity3D, at

Multiple controls

In this section, you will learn how to use several controllers that independently manage different characters. This script will return a subclass of the GameController class. This depends on the controller; it can also return an OuyaController class. You should check what is returned and type a set accordingly.

[ 85 ]

Advanced OUYA Functions â&#x20AC;&#x201C; Graphics and Controls

We can create a script by performing the following steps: 1. The first step in establishing our second player is to select the SkeletonData folder by navigating to Assets | Ouya | Examples | Models and incorporate it into the scene. The 3D model assigned to the controller will look as shown in the following screenshot:

2. For this section, it is important to note that the discrimination between the controls of each character stem from the OuyaInputHandler class, as shown in the following code: Public class OuyaInputHandlerExample : MonoBehaviour, OuyaSDK. IPauseListener, OuyaSDK.IResumeListener

[ 86 ]

Chapter 7

3. The OuyaInputHandlerExample.cs file has an enumeration that is used for the entry that corresponds to a specific control, and this enumeration is as follows: public OuyaSDK.OuyaPlayer player;

Multiple controls

[ 87 ]

Advanced OUYA Functions â&#x20AC;&#x201C; Graphics and Controls

4. It is important to note that you should incorporate the character controller script and set the animations in the new character, as shown in the following screenshot:

Animation settings

5. The OuyaInputHandlerExample.cs file has a filter that links a GameObject to each player. By doing this, we ensure that the various control actions belong to a specific character. This is shown in the following code:

[ 88 ]

Chapter 7 void HandleButtonEvent(OuyaSDK.OuyaPlayer p, OuyaSDK.KeyEnum b, OuyaSDK.InputAction bs) { if (!player.Equals(p)) { return; } if (b.Equals(OuyaSDK.KeyEnum.BUTTON_O) && bs.Equals(OuyaSDK.InputAction.KeyDown)) { this.animation.Play("attack"); } }

The following controller button mapping list is a guide for the newly designed OUYA controller. There exist multiple controller types, and these keys are specific to those controllers with a setup that includes four buttons, two triggers, two shoulder buttons, two analog sticks, and a directional D-pad, as shown in the following code: controller.o controller.u controller.y controller.a


Button Button Button Button


The The The The


button button button button - Button - The L1 shoulder button - Trigger - The L2 shoulder trigger controller.rb - Button - The R1 shoulder button controller.rt - Trigger - The R2 shoulder trigger controller.leftStick - Joystick - The left ouya joystick controller.rightStick - Joystick - The right ouya joystick controller.dpad - Directional Pad - The directional pad

Common problems

In this section, we will deal with the commonly faced issues in OUYA while using multiple controllers.

[ 89 ]

Advanced OUYA Functions â&#x20AC;&#x201C; Graphics and Controls

Controller always pairing as the second controller

Firstly, unplug any USB mouse, USB keyboard, USB HDD, or another USB controller. Some users have reported these taking up a controller slot. If that fails, or you don't have anything else plugged in, try navigating to Manage | System | Advanced | Bluetooth and check if there is a phantom controller in the list (one that isn't the one you are using) and delete it from the list.

The second OUYA controller paired as the third controller

This is a situation where you paired the second controller and it paired itself as the third controller, even though you only had two controllers connected. We need the second controller to be recognized by the console as controller number 2. To correct this error, perform the following steps: 1. Navigate to Manage | Controllers. 2. Go to Bluetooth, and using the malfunctioning controller, select the OUYA Game Controller option and end the connection. 3. Go back and try and repair it.


In this chapter, we evaluated the different shaders and their processors to create optimized games for the OUYA console. We also covered how to use multiple controllers. In the next chapter, we will evaluate the future of the OUYA console and other technologies that help develop new hardware tools for it.

[ 90 ]

The Future Technology is changing the world. Devices and sensors that facilitate interaction between man and machine are becoming more widespread. This holds true in the world of video game consoles, too. This chapter will deal with some of the latest innovations related to the OUYA game console.

Distribution Systems

Major developments in the field of OUYA have been made in recent years. Among these innovations are Nuidroid and Arduino, which have a clear and well-defined potential to interact with the OUYA console. OUYA is a console that will evolve over time in the same way through the interaction and input from its users, allowing further changes and new features to be introduced.

The Future

Virtual reality â&#x20AC;&#x201C; using Oculus Rift

Oculus Rift is a virtual reality head-mounted display. When it was in the conceptualization stage, as a Kickstarter project, large companies such as Epic Games and Valve were interested in its initial development. OUYA is currently working to adapt stereoscopic devices for use with the console.

Oculus Rift

The CEO of Oculus Rift, Brendan Iribe, is planning to work on mobile platforms, but as of now, the company is focusing on PC platforms. Actually, the Android port is already under active development. For more information on and advances in the Oculus Rift development process, go to One of the best discussion threads on the topic of Oculus Rift OUYA integration can be found at [ 92 ]

Chapter 8

There are multiple guides that show you how to integrate Oculus Rift with Unity. The following are some of the best ones: • Integration_Guide


Arduino – the peripheral interface

The purpose of integrating OUYA with Arduino is to gain the ability to leverage the opportunities presented in physical computing, as shown in the following figure:

Arduino and Unity3D

Arduino hardware presents the option to create peripheral devices or "gadgets" that can be used to increase the interaction with a user. Through the use of Arduino-based hardware, we can create free hardware and gain the ability to create gadgets that can integrate with Unity3D, which is a system that has helped the growth of the console.

[ 93 ]

The Future

For more information, visit the following web pages. They contain a lot of useful pointers to use Arduino:

The following link explains the serial connection system for Unity3D programming with Arduino:

The following link leads to a downloadable PDF file on connecting Arduino to Unity. It is called Merging Physical and Virtual by R. Yagiz Mungan:

The following thread further talks about the details and is full of talented developers who have been working on integrating Arduino with Unity3D:

Leap Motion

Leap Motion is a peripheral device that can recognize the gestures of the hands and fingers, allowing us to implement a computer program's commands, as shown in the following screenshot:

Leap Motion

For more information, visit [ 94 ]

Chapter 8

Nuidroid â&#x20AC;&#x201C; 3D recognition for OUYA

Nudroid is a 3D motion sensor, similar to the kinect device that works with Xbox 360. The creator of this project is a Russian company, 3divi, that develops a sensor called Nuidroid, which is targeted at Android devices.

The Nuidroid sensor and OUYA

This device has the possibility to recognize body movements and perform facial recognition. Also, you can tailor additional peripherals to extend the functionality of the recognition, as shown in the following screenshot:

Nuidroid's motion recognition

This is the official website of the company:

[ 95 ]

The Future

The first ever 3D gesture recognition used in OUYA can be found at http://

OUYA â&#x20AC;&#x201C; the Free the Games Fund campaign

The developers of OUYA have started using the Kickstarter platform again; this time, they are using it to fund new games. The difference is that they aim to boost the funds raised by the Kickstarter campaigns by matching the raised funds. This new approach seeks to motivate developers to direct their efforts to produce high-quality content for the OUYA console. In the Free the Games Fund campaign, the steps shown in the following screenshot must be performed for projects to have a chance to win and be part of the million dollars that OUYA will distribute among the gamers whose Kickstarter campaigns reach a minimum of $10,000:

[ 96 ]

Chapter 8

The video games shown in the following screenshot are funded by the Free The Games Fund campaign:

The contest started on August 9, 2013 and will run until August 9, 2014. All the campaigns run by the developers must finish in that span of time. A condition applied to all the projects that are given the award is that the game must be an OUYA-exclusive title for a period between one and six months, and the value of the prize must be proportionate to the time period. OUYA will match the value obtained in each campaign up to a maximum of $250,000. This implies that there will be at least four winners. The matching funds will be paid out as follows: • 50 percent: This is paid when you provide a functional beta • 25 percent: This is paid when your game launches on OUYA • 25 percent: This is paid when the exclusive-to-OUYA period ends More information is available on the official site at

[ 97 ]

The Future


This chapter shows you new technologies that, directly or indirectly, affect the world of video games, the virtual reality, and even the OUYA console. Among these are Oculus Rift, Arduino, Leap Motion, and Nuidroid. In this chapter, we also mentioned the Free the Games Fund campaign that seeks to motivate developers to produce new titles for the OUYA console.

[ 98 ]

Index A


ADB connection USB error 47 Adobe Air about 14 OUYA examples, URL 14 OUYA official documentation, URL 14 URL, for downloading 14 analog joystick and touchpad, differentiating 57, 58 Android Application Package file (APK) 39 Android Development Tools (ADT) 24 Android native development kit. See  Android NDK Android NDK. See also Android SDK Android NDK installing 22 URL, for downloading 14 Android SDK about 14 configuring, in Unity3D 26 installing 18, 21 OUYA examples, URL 14 OUYA official documentation, URL 14 URL, for downloading 14 Android SDK tab 41 Arduino 93, 94

C for Graphics. See  CG CG about 77, 80 syntax 80 Configuration section 61 console about 10 installing 28 Consumable option 66 content restrictions 11 controller about 49 assigning 54, 55 first scene, creating 51-54 setting 50, 51 specifications 9, 10 control pad features 49, 50 Corona about 14 OUYA examples, URL 15 OUYA official documentation, URL 15 Crunchyroll about 13 URL 13

B button description 50 button state changes 58, 59

D developer account 27 developer UUID 27 Download ODK button 30



Eclipse installing 23 plugin, installing in 24 Eclipse error 46 emulator prerequisites, for Mac OS 30 prerequisites, for Windows 30 project, testing with 72, 73 emulator error 45, 46 Entitlement option 66 errors, OUYA about 45 ADB connection USB errors 47 Eclipse errors 46 emulator errors 45, 46 OUYA panel errors 47

Identification section 60 installation Android NDK 22 Android SDK 18-21 Eclipse 23 Java Runtime 18 ODK plugin 39 Unity3D 24 Intel x86 Atom System package 46

F fixed function shaders 79 Free the Games Fund campaign about 96, 97 URL 97

G game compiling 60 creating, in OUYA store 67 executing 60 GameController class 85 GameMaker about 15 OUYA examples, URL 15 OUYA official documentation, URL 15 URL, for downloading 15 gamer account 27 GLSL 77 Graphics Processing Unit (GPU) 76

H hardware specifications 8, 9

J Java class configuring 42 installing 42 Java Development Kit (JDK) 23 Javadoc folder 37 Java JDK tab 41 Java Native Interface (JNI) 14 Java Runtime installing 18

K Key.der file creating 68, 69 Kickstarter 7

L Leap Motion about 94 URL 94 libs folder 37 licenses folder 37 lighting about 82 multiple controls 85-89 setting up 82-85 LitJson folder 38 LogCat 32

M Mac OS ODK, setting up for 30 [ 100 ]

menu button 56 Micro USB (one port) 9 MonoGame about 15 OUYA examples, URL 15 OUYA official documentation, URL 15 multiple controllers, issues about 89 controller, pairing as second controller 90 second OUYA controller, pairing as third 90

N NDK downloading 22 Nuidroid about 95 URL 96 NVIDIA Tegra 3 (T33) processor 8

O Oculus Rift 92, 93 ODK files, downloading 29, 30 setting up, in Mac OS 30 setting up, in Windows 30, 31 ODK plugin configuring 39, 41 for Unity3D, scenes 44, 45 installing 39 within Unity3D 38 within Unity3D, importing 38 onGenericMotionEvent button 59 onKeyDown button 59 onKeyUp button 59 Onlive about 13 URL 13 OUYA about 7, 8, 17, 96, 97 branding 12 branding guidelines, URL 12 content, restrictions 11 controller 49 development tools 13

game consoles 91 SDK development, installing for 29 technical specifications 8 website 8 OUYA account creating 27 developer account 27 gamer account 27 OuyaController class 58 OUYA Development Kit. See  OUYA ODK OUYA emulator configuring 32-34 executing 35, 36 Ouya folder 38 OUYA Framework APK file 37 OUYA game content, guide 70, 71 OUYA game content build settings 71, 72 OuyaInputHandler class 86 OUYA Launcher APK file 37 OUYA marketplace access, programming 69, 70 purchase items, configuring 65-67 user profile, updating 63-65 OUYA ODK about 37 folders 37 OUYA ODK, folders Javadoc 37 libs 37 licenses 37 OUYA Framework APK file 37 OUYA Launcher APK file 37 samples 37 OUYA panel error 47 OUYA store game, creating 67, 68 Key.der file, creating 68

P PLEX about 13 URL 13 plugins folder 38

[ 101 ]

processors, shaders fixed function shaders 79 types 78, 79 vertex/fragment shaders 79 vertex shaders 79 project testing, with emulator 72, 73 purchase items, configuring 65-67

S samples folder 37 SceneInit starter Kit 60 Scenes folder 45 SDK development for OUYA 30 installing, for OUYA 29 ShaderLab 77 shaders about 76 creating 77 fixed function shaders 79 prerequisites 77 processors, types 78-80 vertex/fragment shaders 79 vertex shaders 79 software specifications 10 Starter kit examples 44 system button 56

T technical specifications controller 9, 10 hardware 8, 9 software 10 Tegra 3 processor characteristics 81 touchpad and analog joystick, differentiating 57, 58 TwitchTV about 12 URL 12 Type field Consumable option 66 Entitlement option 66

U Unity3D about 16 Android SDK, configuring 26 installing 24 ODK plugin 38 ODK plugin, importing 38 Unity3D software OUYA examples, URL 16 OUYA official documentation, URL 16 URL, for downloading 16 Update() function 55 USB 2.0 (one port) 8 user identifying 42, 43 user profile updating 63-65 UUID code 42

V vertex/fragment shaders 79 vertex shaders 79 VEVO about 13 URL 13 video game uploading, to OUYA store 64 Virtual Device configuration 32-34 Virtual Device Management option 32

W Windows ODK, setting up 31 Windows 8 driver signature verification disabling 31, 32

X XBMC about 12 URL 12

[ 102 ]

Thank you for buying

Getting Started with OUYA About Packt Publishing

Packt, pronounced 'packed', published its first book "Mastering phpMyAdmin for Effective MySQL Management" in April 2004 and subsequently continued to specialize in publishing highly focused books on specific technologies and solutions. Our books and publications share the experiences of your fellow IT professionals in adapting and customizing today's systems, applications, and frameworks. Our solution based books give you the knowledge and power to customize the software and technologies you're using to get the job done. Packt books are more specific and less general than the IT books you have seen in the past. Our unique business model allows us to bring you more focused information, giving you more of what you need to know, and less of what you don't. Packt is a modern, yet unique publishing company, which focuses on producing quality, cutting-edge books for communities of developers, administrators, and newbies alike. For more information, please visit our website:

Writing for Packt

We welcome all inquiries from people who are interested in authoring. Book proposals should be sent to If your book idea is still at an early stage and you would like to discuss it first before writing a formal book proposal, contact us; one of our commissioning editors will get in touch with you. We're not just looking for published authors; if you have strong technical skills but no writing experience, our experienced editors can help you develop a writing career, or simply get some additional reward for your expertise.

Flash Game Development by Example ISBN: 978-1-84969-090-4

Paperback: 328 pages

Build 9 classic Flash games and learn game development along the way 1.

Build 10 classic games in Flash. Learn the essential skills for Flash game development.


Start developing games straight away. Build your first game in the first chapter.


Fun and fast paced. Ideal for readers with no Flash or game programming experience.


Some of the most popular games in the world are built in Flash.

Learning Libgdx Game Development ISBN: 978-1-78216-604-7

Paperback: 388 pages

Walk through a complete game development cycle with practical examples and build cross-platform games with Libgdx 1.

Create a Libgdx multi-platform game from start to finish.


Learn about the key features of Libgdx that will ease and speed up your development cycles.


Write your game code once and run it on a multitude of platforms using Libgdx.


An easy-to-follow guide that will help you develop games in Libgdx successfully.

Please check for information on our titles

Ouya Unity Game Development ISBN: 978-1-78355-970-1

Paperback: 118 pages

Your guide to building interactive media-rich 3D games with Ouya 1.

Learn how to create and polish your game, and then monetize it with in-app purchases.


Discover what's required to make your game run on Android phones and tablets.


A step-by-step guide that will teach you how to build a fun, challenging game from scratch.

HTML5 Game Development with GameMaker ISBN: 978-1-84969-410-0

Paperback: 364 pages

Experience a captivating journey that will take you from creating a full-on shoot 'em up to your first social web browser game 1.

Build browser-based games and share them with the world.


Master the GameMaker Language with easy-to-follow examples.


Every game comes with original art and audio, including additional assets to build upon each lesson.

Please check for information on our titles

Getting Started with OUYA console - May 2014