Life @ NCP

not everyone needs to go outside to have fun

PAF #2 Show and tell

Download a copy from here – Do give it a shot with a friend or two and let me know what you think!

Horrendous code is available at

It’s basically a port of the first level of Hyper Bishi Bashi, Karate Master! (See this video , approx 16s in) with various tweaks and omissions

Main features:

  • 2p over a network
  • 1p easy, medium, hard, high scores and how to play


  • If using WiFi tethering, the WiFi provider needs to be the client. Didn’t have time to find out why :/
  • Only one game can be played on the network. I’ve set the client to auto connect to the first available server 🙂
  • The random seed is not so random
  • Various exciting bugs and clipping/alignment issues

Here’s some pictures from the simulator:

I wrote it using the Corona SDK , which should mean someone with an Apple Dev license would be able to take my code and compile it straight for iOS devices and play with someone using an Android device. I’m not as happy with this fortnight’s project though, mainly because I didn’t do very much up front planning and the development suffered, both from a lack of clear direction and a lack of understanding some basic ideas behind the SDK. I wasted much time flip-flopping between what to use, and the design / what passed for architecture grew organically, which made for some pretty horrendous code.

Main takeaways:

  • Enough upfront planning needs to be done before starting on a PAF. At the very least this should include:

    • A clear idea of what I’m actually building. It doesn’t have to be detailed, something like this napkin should be sufficient
    • Commitment to a base technology stack
  • The development loop with Corona is pretty cool. Its promise is you can write your code in lua, and it will compile down to iOS and Android. They’ve built their own simulator for the devices that loads, refreshes and is playable in a fraction of the time (not sure about iOS devices, but the native Android simulator takes a while between app restarts). My loop was effectively change -> refresh -> play in less time than a page refresh. That said

    • There is no support for key presses in the simulator. Android’s back soft key button usually needs special handling
    • The simulator is not always accurate, there were a number of clipping and scaling issues between what was shown on the simulator and what was shown on bigger screen phones like an S4
    • You need at least Corona Enterprise (non-free) to access platform-native components not provided by the SDK, e.g. if you wanted to use WiFi direct that’s not provided out of the box by Corona, you’ll need to fork out some moola.
    • Lua feels clunky and immature next to Java or javascript. There is less depth and variety of libraries available for it, and its data structures are somewhat primitive. Seriously, it doesn’t have native support for finding an element within an array. Its arrays aren’t even strictly arrays, they’re tables (approx. a map) that have indexes as keys. Its array indices also start at 1  not 0 which tripped me up numerous times. On the flip side, it’s a small, compact javascript-like language that’s easy to pick up and get started with
    • (Free) IDE support  and native device debugging is non-existent
    • The SDK is also only available on Mac and Windows. Wine on Ubuntu works for the most part till you have to generate an APK. I ended up using wine for my dev loop, but running a windows virtualbox for doing the APK generation. On a side note, I was floored to find IE VMs being supported, maintained and made publicly available by Microsoft for testing.
    • Far and away though, the most troubling thing about using Corona is builds are done by  the Corona cloud. To generate an APK, it submits a request to the Corona build servers and hands you back an APK after voodoo. As far as I can tell, iOS devices have a similar process. Users of the free version SDK have to wait ~20s before their build starts. It also means if their build servers have a problem, you’re pretty stuck :/ There’s also a 100K revenue limit, but I’d be pretty happy with 100k 🙂
    • Despite all this, prototyping something simple in Corona is quick and easy because of the quick loop and small language. Which also means it’s really, really easy to write spaghetti code.

This post probably sums up much of the problems with the SDK itself and provides suggestions for a way forward from someone who has been using the SDK extensively. At the end of it, my feeling is if I needed to write something that would work on iOS and Android quickly, I would probably go with Corona today. If I only needed to support Android, I would probably go with a native Java stack.