Hi, I'm Alex Pretzlav

I write apps for humans, love to cook, and tinker with electronics. I live in Austin, TX.

OUYA Game Jam: The Start

18 January 2013

I’ve always been a gaming fan and kept an eye on the games industry, but the one and only game I’ve written was a silly two player pong game for a just-for-fun class senior year of college (taught by the excellent Joe McKay). So, when my friend Lily asked if I wanted to apply my Android experience to coding a game for the OUYA/Kill Screen CREATE Game Jam, I decided to take a chance on learning a bit more about this whole game programming thing.

Lily already had a vague gameplay idea, working title Noah’s Art, where the player would switch color filters which would effect how they could interact with differently colored objects in a top-down world. Her friend Josh joined in to help with gameplay design. I started by researching different game engines for Android. Of the simple open source Android libraries, LibGDX seemed the best maintained, had the most community support, and good 2d support. Then there’s Unity, a very popular commercial library that supports every platform under the sun, is a sponsor of the jam, and looks like it does a lot of work for you if you can figure out how to use it. In the end the deciding factor wound up being the wifi at the coffee shop I was working at on Monday: the 1GB+ Unity download kept getting cut off. I was also concerned about the hefty price tag on Unity, while LibGDX let me avoid those concerns.

Game Day 2: Things on screen
Noah's Art Day 2: Things on screen

I started with LibGDX by working through Tamas Jano’s excellent “Getting Started in Android Game Development with libgdx”. After a morning spent kicking the tires on LibGDX I started a new game project with a 720p screen targeting OpenGL 2.0 to match the OUYA’s specifications. Now that I remembered how game loops worked, which LibGDX handles for you by repeatedly calling the render() function on your Screen class, it was time to get to work. I easily ripped off the Invaders sample code to draw a temporary background image and rendered a temporary sprite at a fixed coordinate as a stand-in for a game object.

The first task was getting a cursor to display on screen, as the player will manipulate wandering animals with a cursor controlled with one of the OUYA controller thumbsticks. I added support for the OUYA controller using LibGDX’s new controller support (I also added mouse controls for LibGDX’s desktop mode for development testing). It turns out getting controller state in LibGDX is pretty easy: on every game loop just check where the stick is and set the cursor’s velocity accordingly, then update its location based on that velocity. The stick axis value is a fraction between -1 and 1 to denote all the way down or all the way up:

The > 0.2 check is to account for sticks not quite going back to center, a common problem.

After that it’s a simple matter of drawing the cursor at its new location:

Voilà! You’ve got a cursor you can move with the thumbstick. Now, about that fixed temporary game object … tomorrow: things that move!