• Word Up Dog: Creating Android apps with Adobe Air

    A screenshot of Word Up Dog the game
    Word Up Dog: represent, yo!

    Having already optimized my game Word Up Dog so that it runs relatively well in a browser on an Android phone, I was ready to package it up as an installable app. Adobe Air makes this easy to do with few changes to your original code. Adobe has a Flash CS5 plugin to do it, but I prefer to do things the free-and-open way when I can, so here’s how I built the Android app using only FlashDevelop and other free Windows tools.

    First, I don’t recommend the Android emulator. I struggled with getting emulator-compatible versions of the Air packager and Air runtimes installed. There didn’t seem to be much advantage so use a phone if you can get your hands on one.

    I followed several tutorials and honed the process down to this:

    1. Download the Air 2.5 SDK, paste it into a copy of your Flex SDK directory, and set FlashDevelop to compile using the result
    2. Start a new FlashDevelop AIR AS3 project
    3. AddChild your existing game in Main.as
    4. Add NativeApplication handlers to prevent the phone from idling
    5. Add android-specific settings to application.xml (here, have mine)
    6. Generate a certificate using
      adt -certificate -cn WordUpDog 1024-RSA certificate.pfx yourpass
    7. Build your air project to create WordUpDog.swf
    8. Package the swf into an apk file with
      adt -package -target apk -storetype pkcs12 -keystore certificate.pfx -storepass yourpass WordUpDog.apk application.xml -C . WordUpDog.swf iconsFolder
    9. Upload WordUpDog.apk to your phone and baby, you’ve got a stew going
    Word Up Dog on a Nexus One
    Victory – the Air for Android app is installed!

    I was prompted to install the Air interpreter the first time I ran the game on my Nexus One, then it behaved just like any other app. The performance was about the same as running the SWF through the phone’s browser, but of course there are advantages to being installed. I could force the game to stay in landscape perspective and add a customized handler to deal with incoming phone calls. Not to mention being able to upload and sell it on the Android app store!

    Next I’ll tackle Air on the iPhone.

  • Word Up Dog: Flash optimization for mobile platforms

    Word Up Dog Splash Screen
    Word Up Dog: Yo Diggety.

    I just put my new game Word Up Dog up for bidding on FlashGameLicense. It’s very different from my first game Rebuild (I needed a break from zombies!). In Word Up Dog, you play a dog digging underground for letters to anagram, aided by cute animals who speak in 90’s hiphop lingo. It has a simple interface and can be played in short sessions, so it’s a good fit for mobile platforms like the iPhone, iPad and Android phones.

    When uploading a game to FlashGameLicense, one of the options is a “Mobile-ready” checkbox. Here’s what I did to make Word Up Dog mobile ready…

    I have a Nexus One Android phone, which unlike the iPhone can run Flash in its browser. So as a first test I pointed it at the totally unoptimized game swf. I was pleased to see the game load quickly and error-free, and the graphics looked good on the bright little screen. The SimpleButtons were easy to hit and the mouse over state even showed briefly. Movement using both the trackball (which fires up/right/down/left KeyboardEvents) and touch worked correctly. But the framerate was crappy, and touching even a blank area on the screen brought the game to a crawl.

    First, I looked at how I was rendering the map, a 800×550 sprite containing ~150 vector shape tiles. The tiles had cacheAsBitmap=true which had a noticeable effect on my pc, but it was hard to tell if it was doing anything on Android. Instead I manually drew each of the tiles to a Bitmap, which improved the framerate significantly. Drawing all the tiles onto one huge 800×550 bitmap was even better, but the way my tiles overlap made updating (by blitting) difficult.

    I improved the movement speed by jumping the screen from square to square instead of smoothly scrolling it. I downgraded the target fps from 30 to 24, and simplified the gui animations so that instead of fading in, notice text pops into existance. I replaced contrast, emboss and drop shadow filters with graphical approximations. I cached the dog’s shape tween animations as Bitmaps using TouchMyPixel’s AnimationCache. Each of these things had a small but helpful effect on the framerate.

    Now to tackle the touch issue. Holding down on any part of the screen lowered the framerate by 10fps, even after stripping out all MouseEvents. I couldn’t recreate it on pc (even via air at 250fps) or see evidence of it in a profiler. My guess is that Flash just isn’t very efficient at dealing with touch screens. What finally improved things was setting mouseEnabled=false and/or mouseChildren=false to everything in the game that isn’t meant to be clicked. This seems to be especially important for TextFields.

    Flash Preload Profiler
    Tracking memory with the Flash Preload Profiler

    Finally, memory. The free FlashPreloadProfiler told me I was using 50mb, and showed the number of instances of each class and time in functions. Adobe’s Flash Builder Pro profiler gave me additional info including function stacks and the momeory used by each class.

    I got my memory down to 20mb by instantiating some map-related things when they came into view rather than at game start. I verified that I didn’t have any memory leaks such as objects or handlers left around after exiting to menu and starting a new game.

    To recap my optimizations:

    • Draw shapes to Bitmaps instead of relying on cacheAsBitmap
    • Simplify gui animations
    • Cache character animations as Bitmaps
    • Remove filters
    • Set mouseEnabled=false and/or mouseChildren=false on non-clickables
    • Other best practices I follow include cutting down on EnterFrame events, avoiding masks, and using strongly-typed variables.

    I can now run Word Up Dog on my phone through Chrome at 20-24 fps! Not perfect and it will be slower on older phones, but I’m calling it a success. In my next post I’ll talk about packaging the game up using Air so I can sell it in the Android and iPhone app stores.

  • Super Crate Box tells us the magic number is 600

    Hats off to Vlambeer for making Super Crate Box. A great single screen platformer. Before it was nominated for a design award at the IGF it was nominated for love by the judge in my heart. And in my heart it took the grand prize.

    I found Super Crate Box while we were in Honduras and when you’re at the end of an impassable dirt road with no TV and spotty Internet what you really need on your hard-drive is a good super-hard game with both running and gunning. I played the hell out of it and am proud to have 100% unlocked everything.

    So why is it so fun? To answer that it would be helpful if you had at least a passing understanding of Super Crate Box (no I will not be acronyming that). There’s really no reason I should have to describe it to you. Just go play It. It’s free and more fun than reading.

    During my Super Crate Box phase we made a trip to Pigeon Keys with our friends Julie and Ed who run Radical Adventures. It was an amazing trip! We’d done a lot of snorkeling before but the waters off Pigeon Keys were perfectly clear. So clear it was like there was no water at all and we were flying 10 meters over the ground in a giant beautiful Catamaran pointing out fish and rays like you might point out birds. Diving off the boat became like bungee jumping. This one novel twist on an experience we had had many times before made it go from fun to once-in-a-lifetime amazing. Our brain loves to be in a familiar situation with a twist because it loves to learn.

    Video games are about learning and our brains do a lot of learning through pattern matching. When we have a decision to make we compare the situation to previous situations we’ve been in. If we can can find an identical one and we know how to solve it then we just do the same thing we did back then. If we can’t associate it with a previous situation at all we panic and do something random. But if it’s similar but slightly different to a previous situation, or better, is a combination of previous situations then we get creative. We try a combination of stuff that worked before. And this can be genius. This is an incredibly powerful tool evolutionarily so it makes sense that our brain likes to do it and it’s fun.

    Super Crate Box is in the business of giving us these slightly-different problems to tackle. It has dedicated its life to this task and I applaud it for its selfless dedication to making me joyful. It manages this by taking a simple proven game (jumping around and shooting stuff) and combining it with a dizzying array of weapons, all of which are slightly different from each other. “But that’s hardly new, lots of games have a dizzying array of weapons” you say. Yes that is true, imaginary reader in my head, you are correct. But Super Crate Box knows you’re too shitty a game designer to use them properly.

    Games are about learning and our brain really likes to learn. But it doesn’t like to learn just any old things. It likes to learn helpful useful things. It wants to learn how to win! Most games with a dizzying array of weapons let you chose which ones you want to play with. Super Crate box recognises this as a fault. The better you get with a weapon in Super Crate Box the less you play with it. The better you are with a weapon the more ruthlessly efficient you are at getting to the next crate and the next random weapon. In this way Super Crate Box refuses to let you specialise. It refuses to let you get good with one weapon and ignore all the others, which is how I (and I assume most people) play all those games with a dizzying array of weapons. We play games that way because our brain recognises that its often more efficient to get better with something we understand than to start over learning something we don’t. Unfortunately that’s less fun but our brain is a shitty game designer.

    By forcing us into a situation we’ve already been in but with an unfamiliar weapon Super Crate Box gives us a problem we can tackle creatively. And when we succeed at one of these problems it feels great! In fact it’s probably possible to mathmatically determine the number of possible situations and therefore the number of situates which should be contained in the perfect game (assuming Super Crate Box is the perfect game). Say there are 15 weapons (amazingly I can’t find a list) and say there are 40 unique board states (I’m pretty much just making that up) that means there are 600 totaly states. So take a look at your favorite game or the game your making and count the states. 600 = IGF Design Nomination!

    Anyway, once more doff your hat to Raimi Ismail and Jan Willem Nijman for being smarter than the human brain and giving us all something slightly different to play.

     

    Also thanks that there is this

  • A Day In the Life of a Traveling Game Author

    It occured to me that some people might be curious about what life as a traveling game author is like. I decided a good way to give you a look into our every-day life would be to write up a day-in-the-life. Here, presented for your edification, is yesterday:

    I woke up at about 6:00 am. I don’t know what it is about the tropics but Sarah and I tend to get up with the sun. Our Internet is usually pretty good in the morning so I reached for the laptop and checked the emails and the facebooks. After tooling around online for an hour or so I got up and greeted the day.

    As Sarah slept I wandered down to the beach. I couldn’t see another soul on the eight kilometer stretch of sand and as I walked I left the first footprints since last night’s high tide. It was before the heat of the day and I waded across a few low streams as I mulled over game design problems. I had done my first in-person playtest the previous day so I had a lot to think about. I like to walk and move around when I’m thinking and I like to be somewhere interesting when I think about game design. I’m not sure what role conscious thought plays in coming up with novel ideas and solutions but sitting on a log and watching hermit crabs scurry around seems to generate a close to optimal mindstate. As I was watching the hermit crabs I had a great idea. Actually it was a really old idea that had been rattling around in my head since I first started working on the game. Only now, four months later, was it apparent that this idea might be the puzzle-piece I needed to solve my problems. Play testing is a magical thing.

    contemplationWell when you have a perfect puzzle piece in your head you can’t sit around watching hermit crabs. You have to go slot it into the puzzle! I wandered back over the streams and found Sarah awake and eating breakfast. We talked about some crazy bugs she’s trying to track down in her game Word Dog while I ate some (very unexotic) corn flakes. After I slotted the puzzle piece in I started playing with the new version of the game. It felt really good and I had Sarah give it a play to get a second opinion. It was working really well for her as well and I started to get excited as I imagined other people really liking it. This feeling is like mother’s milk to indie game devs. The thought of players feeling that same soaring joy that you feel playing your game is what keeps you going through the months of doubt and grunt work.

    But you can’t do grunt work with an empty stomach and we were in serious need of supplies. We grabbed a backpack, locked up the house, and headed for the beach. We live in Pochote, a tiny fishing village. You can get fish here but not vegetables. To get groceries we have to walk down the eight kilometer beach to Tambor. It’s a long way back and forth in the Costa Rican heat but as far as grocery trips go an 8k walk down a sandy beach butressed by palm trees with scarlet macaws flying over your head isn’t too bad. On the way back we stopped for an hour of body surfing in the larger than average waves.

    We go on a lot of walks no matter where we are in the world and the conversation is usually dominated by talk about games. I really like walking to think about game design. You’re seeing new and interesting things around you and this seems to fire off odd and productive thoughts. Where ideas come from is a grand mystery to me but filling your eyes with exotic sights and talking about what you’re thinking with another game author seems to bring them out of hiding.

    When we get back I’m excited enough to grab the laptop and head next-door to do a little more in-person play testing. We live next to a bar and children’s music school run by a family of Canadian Costa-Ricans. That sounds like an odd mix and maybe a mix that you wouldn’t want to live next to without ear protection but that’s really not the case. Harmony Music School and Gabe’s Bar are as wonderfully as the family running them. They’ve made this tiny fishing village one of our favorite places in the world and they’re in competition with places like Tokyo and Istanbul and Edinburgh. The best part of travel is the people and the people here are great.

    Gabe is about our age and is my local play-tester. If the game was in a more finished state I’d get everyone I could lay my hands on to play it but as it is Gabe’s English-speaking, game-literate, mind is a perfect and rare commodity. I trucked my laptop over to the bar and Gabe sat down to give the new version a play. His reaction was really gratifying. He lamented some of the quirks of the old system disappearing but was immediately sucked into the game more deeply than before. I find it easier to trust players behaviour rather than their words so when he ran out of levels and just started playing around randomly for fun I was a happy person.

    By this point it was about three o’clock. I probably should have gotten back to the house and done some more work but instead I spent the next several hours playing pool. I have to admit, I don’t work super hard, but this day was pretty lazy even by my standards.

    Sarah was beavering away on the deck when I dropped off my laptop and I could not entice her to abandon her work to skive off with me and play pool. Not until the impromptu pot-luck started up did she make it across the yard to Gabe’s. A couple of local musicians had decided to put on a little show last night so people started wandering over to Gabe’s at about 5:00. By happenstance a lot of them had food with them. We ate Jambalaya, fish caught out of the ocean an hour earlier, and, amazingly, freshly made Kimchee! Freshly made Korean Kimchee in Costa Rica! Thank you Kee Bum!

    The concert was great and the evening was filled with the student musicians, local fishermen and guides, expats, and all the rest laughing drinking and eating.

    That’s what being a traveling game author is like. It’s like being a regular game author but much much better.

  • Oysters & Puppies & Good times


    Shakira & her pups
    Originally uploaded by apes_abroad.

    A couple days ago Colin and I went out with Don and his friend John on an oyster hunt. We crossed the estuary and walked over the rocks on the point to find a place we could enter the water without being chewed up by the waves. It was a low visibility day so we had to dive down to see the rocky floor and searched for crevices in the rocks where a little black slit of a mouth might be hiding. It took me nearly half an hour to finally bag my first one and I shot to the surface holding it high and singing the A-Team theme through my snorkel.

    I found my second and third by turning over rocks, and in the process also uncovered eels, slugs, and a beautiful big cowrie whose shell was at first totally covered by its bumpy grey body. Then came the biggest, most tenacious oyster which all my tugging could not separate from the rock. The current was picking up as the tide came in, so every time I had to come up for breath I was afraid I wouldn’t be able to find him again. My fingers got all cut up in the fierce battle, but after five tries I shot to the surface holding the oyster over my head in victory!

    That night we had ‘pirates’ at the bar, which is an oyster with chili followed by a shot of rum. When I lifted my oyster to my lips (my tenacious opponent perhaps!) I saw a tiny pair of eyes looking back at me. The oyster had been home to a miniature transparent lobster, smaller than a thumbnail with perfect little lobster claws and wavy eye stalks. People eat these guys live as a delicacy that kind of tastes like sweet fish roe (Aaron ate one while he was here!) but I couldn’t do it. A friend took pity and brought it down to the ocean, where I doubt it will be able to find another oyster (I now know from experience, they’re hard to find!) but one can hope.

    While the Mishkins were here we were all placing bets on when the local dog Shakira would give birth. Well, she looked ready to pop for the last two weeks I thought, but Ariel won the bet – she gave birth within 24 hours after they left. Gabe’s wife Natalia had to crawl down under the bar floor to retrieve the puppies. Four.. five… wait there’s two more.. eight.. oh there’s even more over here.. ten.. eleven! How Shakira, who was not a very big dog, fit eleven puppies in her I don’t know, but she is much happier now to have them on the outside (she could hardly walk before!).

    The puppies still haven’t opened their eyes and only have two states: sleeping and hungry. For me they are right on the gross/cute line but quickly tipping over to cute. You can see what I mean in this short video I took of them piling on Shakira to feed.