My GCP Build-off experience!

I want to share with you all my experience in Google Cloud Platform Build-off, It was a contest where there were 3 categories: Music, Film and Gaming. If you know me you already know in which category I participated! Obviously on music!…of course not! GAMING!

So first of all I saw the ad late! around February 10th! (the contest started on 5th) I had an idea from long time back, but the only thing I had was a character:



A nice and cute character that I wanted to put in a challenging game, I had this idea of a game that will challenge your memory and some other brain abilities. But that was it, that was all I had at that moment. Since I always procrastinate; this time I wanted to do it for real. So I said to myself: “Myself you should really do it this time, you need to have a deadline”. At school I always did the projects at the end of the period, not because I was completely lazy (well maybe a little…) but because I always wanted to do something else. But when the deadline was approaching I was giving my 200% or even 300% to achieve what I wanted to do for that project.

So I challenge myself! and I had to finish it by February 28th! a couple of weeks only! And then I started building the idea into reality, I know Unity and Blender, so I started building everything in Blender, all the environment, the coins and the emeralds.

Screen Shot 2015-03-17 at 10.43.12 PMScreen Shot 2015-03-17 at 10.44.00 PMScreen Shot 2015-03-17 at 10.44.24 PM

Then I started coding all the actions in Unity, I built a Tunnel, that would repeat over and over while the character was running. And I created a framework that would place the coins, emeralds and obstacles in specific places based on templates. Since I didn’t wanted to build each and every single combination on Unity I created this framework that will take a template configuration from an external source and place the elements accordingly. And the external source that I chose was Google App Engine, I didn’t have to code much to create a web server and responde to http requests, it was already there. So I started coding, then I noticed that a file would be very rudimentary to maintain, so I decided to use Google Sheets so that I could go to a spreadsheet and modify it online and the world of the tunnel would change. So I used a set of APIs to get the content and the last modified date time stamp. And then process that content to finally send a clean and light weight response to the mobile client (in JSON).

At the beginning everything looked fine, but then I noticed something interesting, each call was taking around 800 to 900 ms. A noticeable time for an app to wait for an updated world. Since I wanted to reduce the time for that I decided to use Memcache to store the processed information in cache. So all subsequent calls would be faster. When I stored the object the response time for the subsequent requests got reduced dramatically, from 800 ms to 80 – 90 ms!! Incredible! and not a whole lot of code needed. Just like using a dictionary.

Once all this was ready I had only 1 thing to do on the backend: the scores. For this there wasn’t much need, just a place to store unique players and their list of scores. So I easily used Datastore to store these entities. I did all this on the free tier! I didn’t paid a single penny! Which is awesome hehe!

And then after the main flow was working I started “polishing” few things in the app to make it fluid and have the playable experience, I included some sounds and music, and adjusted the volume and length to fit all the sounds into the game and I used Audacity for that. Once everything was ready I had to make a video to publish my participation on the contest:

And the I could sleep! I didn’t sleep for the last 2 days before the contest, I had to do a few adjustments and fixes before I could send the application. But it was worth it! Few days later I received an email from the organizers of the contest! I was in the next round of the contest! It was an amazing feeling. Knowing that my game could actually win the contest, I wasn’t sure how many games were there but for sure mine made it to the next round. Few more days later I received the most exciting news from them again! I have won one of the prizes, they didn’t tell me which, but I was suspecting it from the beginning! They asked me to travel to Austin, TX to showcase the game. I was really excited!! And I prepared myself for the presentation, the first time I rehearsed it was totally a fail! then I practiced a lot with my wife that supported me all the way from day 1! And then finally I flew there to Austin, a lot of exciting things happened there! Lot of stands were there with exciting technology and an awesome set of talks!

When the time came and we started rehearsing the real thing along with other winners and the presenters! The stage was imposing but exciting! And then we knew what was our place!

I WON the first prize on the gaming category!! It was an amazing feeling!! Knowing for sure that I was in the first place!! All the effort…worth it!

So I’m proud to say Tunnel Challenge won the price for the gaming category, maybe is not the next Flappy bird, but is definitely something that I’m proud of! and I’m excited to see it grow and put all the things I put aside to finish it on time!

Please go ahead and download it on Google Play:

It will be available on iOS and Windows Phone really soon!


Google App Engine in games

In my first post I talked about the interesting services that Amazon provides, in this one I’m going to talk about what Google has to offer.
Just as Amazon, Google offer a wide range of different services, but the there is a particular difference between the two of them, GAE (Google App Engine) has a “free” limit that you can use without using any kind of credit card or payment method. So you could publish an entire application without a single penny.

Right now I have an API for the Whack-a-mole game that stores the players scores. One advantage from the cloud that I will be using is that; since I will be testing this at the beginning and then decide if I will choose something different, like backend instances. GAE has a very interesting concept called backend instance. which is nothing more than an application running continuously waiting for a request (like a server). The difference between that and a typical application in GAE, is that the typical applications are sleep. and only run if there is a request. This is useful if your application is intended to work in this way. Since the game is not continuously communicating with the API (only when saving or getting scores). The typical application is perfect for me, because whenever a player wants to store their score an instance of the scripts will be initialized start the quota process the score and then die and stop counting toward the quota. So this keeps the quota low. Since I will not be continuously running the application. Also the typical application schema help me deciding at runtime how many instance I should be running to keep the experience smoothly. Which is something that I really want to keep encapsulated.

Thinking on this scenario:

A player initializes a request to the application to store an score, and by that time another player wants to store an score also, the application will simply initialize one instance for the first one, and then the second one will use the first instance of the application. If the first instance is too busy to process the subsequent requests it will initialize another instance of the application, in this case both instances will count towards the limits defined. But the free limits in GAE are fairly enough, because they have a free limit of 28 hours for a single instance running continuously, and that limit resets every day. So you can run 1 instance continuously the entire day and another instance for a couple of hours, you can see more about limit in this page:

Hope this gives you an idea of how GAE can be used. Let me know any comments or ideas that you have.